# Developers Planet

salam February 2016

### Decomposing the numerator and the denominator polynomials into their even and odd parts

Here there is a continues time transfer function `(G(s))` in form of:

``````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)
``````

and `(s = j*w)` where `w = frequency symbol.`

Now, how is it possible to decompose the numerator and the denominator polynomials of Eq. (1) into their even and odd parts and get the `G(jw)` as (Using Matlab) :

Andras Deak February 2016

You could probably take the real and imaginary parts after the substitution with `s=j*w`. However, you can actually select the even and odd parts of your polynomials:

``````% 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);
``````

and the same for the denominator.