phase.m

来自「OFDM multipath fading channel model jake」· M 代码 · 共 39 行

M
39
字号
% 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 + =
减小字号Ctrl + -
显示快捷键?