📄 phase.m
字号:
% phase.m
% Draw phase response and pdf.
function []=phase(idata, qdata, name)
%****************************** variables *******************************
% idata Ich data
% qdata Qch data
% name Title of the figure
%*************************************************************************
nsamp=length(idata);
% compute phase of fading channel (rad)
theta=zeros(1, nsamp);
for i=1:nsamp
if idata(i)>0 & qdata(i)>0 % the 1st quadrant
theta(i) = atan(qdata(i)/idata(i));
elseif idata(i)<0 & qdata(i)<0 % the 3st quadrant
theta(i) = atan(qdata(i)/idata(i)) + pi;
elseif idata(i)<0 & qdata(i)>0 % the 2nd quadrant
theta(i) = atan(qdata(i)/idata(i)) + pi;
else % the 4nd quadrant
theta(i) = atan(qdata(i)/idata(i)) + 2*pi;
end
end
% Phase Response: Time vs. Phase (rad)
figure;clf;plot(theta);grid on
title(['Phase Response for ', name]);
xlabel('Time');
ylabel('Phase(rad)');
% Probability density function of phase response
step = -0.01:0.01:8;
theta_pdf = histc(theta, step);
theta_pdf = theta_pdf/2/pi/(sum(theta_pdf)./length(step)); % normalization
figure;clf;plot(step,theta_pdf);grid on
title(['pdf of phase for ', name]);
xlabel('phase');
ylabel('pdf');
%***************************** end of file *******************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -