invztrans.m

来自「对输入的一有理Z变换表达式(输入分子和分母系数序列)」· M 代码 · 共 69 行

M
69
字号
%  According to ROC, inverse a transform function to a sequence.
%
function [SEQ, t] = InvZTrans(R, P, K, dividP, Leng)
%  Parameters:
%    R:  Column vectors containing the residues 
%    P: Column vectors containing the poles
%    K: K contains the direct terms in a row vector
%    dividP:  ROC 的分界点的模, 模比dividP小的极点对应的分式逆变换为右边序列, 
%             模大于等于dividP的极点对应的分式逆变换为左边序列
%    Length:  The length of generated sequence.
%  Return Value:
%    SEQ:  Generated sequence by inverse z-transform.
%      t:  Vector of times

[LB, LA, RB, RA] = ROCFactor(R, P, K, dividP);
lengL = length(LB);
lengR = length(RB);

if lengL ~= 0
    % untilize the time-shift property of Z transform to calculate
    %   left-side sequence
    num = fliplr(LB);
    den = fliplr(LA);
    if  Leng > 0
        [yl,tl] = impz(num, den, Leng);
    else
        [yl,tl] = impz(num, den);    
    end
    tl = -tl;
    yl = flipud(yl);
    tl = flipud(tl);
else
    yl = [];
end

if lengR ~= 0
    if  Leng > 0
        [yr,tr] = impz(RB, RA, Leng);
    else
        [yr,tr] = impz(RB, RA);
    end   
else
    yr = [];
end

length_l = length(yl);
length_r = length(yr);
if length_l ~= 0
    if length_r ~= 0
        SEQ = [yl(1:length_l-1);  yl(length_l)+yr(1); yr(2:length_r)];
        t = [tl(1:length_l-1); 0; tr(2:length_r)];
    else
        SEQ = yl;
        t = tl;
    end
else
    if length_r ~= 0
        SEQ = yr;
        t = tr;
    else
        SEQ = [];
        t = [];
    end
end


% ------- End of Function InvZTrans ------------
    

⌨️ 快捷键说明

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