demod_iphase.m

来自「提取信号七个基于瞬时信息的特征:零中心归一化瞬时幅度功率谱密度的最大值,零中心归」· M 代码 · 共 58 行

M
58
字号
function iphase = demod_iphase (yi,yq)

%Gererate the Instantaneous Phase
%
global k Fc Fd Fs n;

N = length(yi);

iphase = zeros(1,N);    % Initialize the iphase.

% if the Inst. Phase is lower than this Threshold, then it's set to 0.
t_phase = 0.001; 

%% yq = sin(iphase)
%% yi = cos(iphase) 

% Inst. Phase is from -pi to pi.
for i = 1:N
    
    if (abs(yi(i)) <= t_phase);    
        
        if yq(i) >= t_phase
            iphase(i) = pi/2;
        else 
            iphase(i) = -pi/2;
        end
        
    end
 
        
    if yi(i) < -t_phase
        
        if yq(i) > t_phase
            iphase(i) = atan ( yq(i)/yi(i) ) + pi;
        end

        if yq(i) < -t_phase
            iphase(i) = atan ( yq(i)/yi(i) ) - pi;
        end
        
        if (abs(yq(i)) <= t_phase)
            iphase(i) = pi;
        end

    end
    
    if yi(i) > t_phase
        iphase(i) = atan ( yq(i)/yi(i) );
    end
    
%    [i,iphase(i)]      % Show the result.
%    pause;
    
end

%figure (921);
%stairs (n, iphase);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?