Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Even/Odd polynomial
Replies: 5   Last Post: Dec 22, 2013 6:23 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alex

Posts: 14
Registered: 12/18/13
Even/Odd polynomial
Posted: Dec 19, 2013 2:22 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Given the transfer function p(s)=b(s)/a(s).

a(s)= ae(s^2)+s*ao(s^2); b(s)=be(s^2)+s*bo(s^2).

where the ae and be are the even polynomials and ao and bo are the odd polynomial.
An example:

p(s)=(s-1)/(s^3+6s^2+17s+18)

ae(s^2)=6s^2+18;
s*ao(s^2)=s^3+17s => ao(s^2)=s^2+17;
be(s^2)=-1;
s*bo(s^2)=s =>bo(s^2)=1.
The matlab code that i wrote is:

ae = [];
ao = [];
if mod(length(a),2) == 0
for i = 1: length(a)
if mod(i,2) == 0
ae = [ae a(i)];
else
ao = [ao a(i)];
end
end

else
for i = 1: length(a)
if mod(i,2) == 0
ao = [ao a(i)];
else
ae = [ae a(i)];
end
end
end
be = [];
bo = [];
if mod(length(b),2) == 0
for i = 1: length(b)
if mod(i,2) == 0
be = [be b(i)];
else
bo = [bo b(i)];
end
end

else
for i = 1: length(b)
if mod(i,2) == 0
bo = [bo b(i)];
else
be = [be b(i)];
end
end
end

I wonder if someone guide me with a code with less lines. Thank you!



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.