将分子和分母多项式分解为偶数和奇数部分

时间:2016-02-08 18:22:42

标签: matlab complex-numbers

这里有一个持续时间传递函数(G(s)),形式为:

G(s) = N(s)/D(s);
G(s) = (s^3+4s^2-s+1)/(s^5+2s^4+32s^3+14s^2-4s+50)     (1)

(s = j*w)其中w = frequency symbol.

现在,如何分解分子和分母 方程的多项式(1)进入偶数和奇数部分并得到G(jw)为(使用Matlab):

enter image description here

1 个答案:

答案 0 :(得分:6)

您可以在用s=j*w替换后使用实部和虚部。但是,您实际上可以选择多项式的偶数和奇数部分:

% G(s) = N(s)/D(s);

syms s;
N = s^3+4*s^2-s+1;

p = sym2poly(N);

%// do this in fewer lines:
%{
/*
if mod(length(p),2)==0  %// then first index is odd
    imin_o = 1;  %// for odd part
    imin_e = 2;  %// for even part
else
    imin_o = 2;  %// for odd part
    imin_e = 1;  %// for even part
end
*/
%} 
imin_o = mod(length(p),2) + 1;
imin_e = 2 - mod(length(p),2);

% odd part of numerator
p_o = zeros(size(p));
p_o(imin_o:2:end) = p(imin_o:2:end);
% even part of numerator
p_e = zeros(size(p));
p_e(imin_e:2:end) = p(imin_e:2:end);

% restore
N_o = poly2sym(p_o,s);
N_e = poly2sym(p_e,s);

和分母一样。