Borrar filtros
Borrar filtros

Extract num and den in symbolic expression.

19 visualizaciones (últimos 30 días)
Bruce Taylor
Bruce Taylor el 24 de Jul. de 2019
Editada: Walter Roberson el 26 de Jul. de 2019
The 'tf' function in Control Systems needs numerator and denometer in a vector of decreasing powers of s.
For example a numerator of a*s^2 + b*s + c needs to be num= [a b c];. I have been cutting and pasting the necessary coefficients
but to do this I have to pause my program. Is there a way to extract the appropriate vector(s) programatically?
Thanks,
Bruce Taylor

Respuesta aceptada

Star Strider
Star Strider el 24 de Jul. de 2019
Use the sym2poly funciton:
syms a b c s
num = 1*s^2 + 2*s + 3;
n = sym2poly(num)
n =
1 2 3
  3 comentarios
Star Strider
Star Strider el 24 de Jul. de 2019
I thought you had already isolated the numerator and denominator.
Try this:
syms a b c d e f g s
sys=(a*s^2+b*s+c)/(d*s^3+e*s^2+f*s+g)
sys = subs(sys,{a,b,c,d,e,f,g},{3,6,8,1,2,9,5})
[np,dp] = numden(sys)
n = sym2poly(np)
d = sym2poly(dp)
producing:
sys =
(a*s^2 + b*s + c)/(d*s^3 + e*s^2 + f*s + g)
sys =
(3*s^2 + 6*s + 8)/(s^3 + 2*s^2 + 9*s + 5)
np =
3*s^2 + 6*s + 8
dp =
s^3 + 2*s^2 + 9*s + 5
n =
3 6 8
d =
1 2 9 5
Note that this will only work with numeric coefficients. It will error with symbolic coefficients.
Walter Roberson
Walter Roberson el 25 de Jul. de 2019
Star Strider is correct, MATLAB transfer functions, tf() and ss(), cannot support symbolic expressions.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 24 de Jul. de 2019

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by