HELPPP!!! polynomial to transfer function?

8 visualizzazioni (ultimi 30 giorni)
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...

Risposta accettata

Teja Muppirala
Teja Muppirala il 6 Mag 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 Commento
Alex
Alex il 6 Mag 2011
BOOOOOOOOOMMMMMMMM!!!! wowww i spent like 5 hours on this.
Thanks Teja

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by