HELPPP!!! polynomial to transfer function?

8 views (last 30 days)
Im am having trouble converting from a polynomial to a transfer function automatically. My matlab program computes a denominator for example x^2+2x+1, and a numerator say x^2+3x+2 (x is a symbol). Now i want the program to automatically make a transfer function from these polynomials. I tried collecting the coefficients like eq1=coeffs(x^2+2x+1) and eq2=coeffs(x^2+3x+2) and put these in tf(eq1,eq2) and i get an error. I found that if i copy paste the results like eq1=[1 2 1] and eq2=[1 3 2] i get what i want. I have really big polynomials to deal with and need the program to do it automatically. thanks for the help...

Accepted Answer

Teja Muppirala
Teja Muppirala on 6 May 2011
Here's an idea.
syms x
eq1 = x^2+2*x+1
eq2 = x^2+3*x+2
s = tf('s')
eq1_s = strrep(char(eq1),'x','s');
eq2_s = strrep(char(eq2),'x','s');
G = eval(eq1_s) / eval(eq2_s)
  1 Comment
Alex
Alex on 6 May 2011
BOOOOOOOOOMMMMMMMM!!!! wowww i spent like 5 hours on this.
Thanks Teja

Sign in to comment.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!