How to extract transfer function coefficient from symbolic functions?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm new in matlab. I have a college project to plot frequency response of user-defined transfer function with GUI by using freqz and my self-made function DTFTIIR (num,den,N) then compare the results. The user will input a function like H[n]= (0.5^n)*u[n] or H[z]=(1+z^-1+z^-2+z^-3)/(1-(0.18*z^-1)+(0.81*z^-2)). First, i think i will declare n and z as symbols. For n-domain functions i think i will use ztrans which will also resulting a symbolic equation in z domain. The problem is, how can i find the numerator and denumerator coefficient matrix from symbolic functions like (1+z^-1+z^-2+z^-3)/(1-(0.18*z^-1)+(0.81*z^-2)?
0 commentaires
Réponse acceptée
Star Strider
le 26 Mai 2014
You can do everyting you want in a fairly straightforward fashion. There are probably different ways to achieve your ultimate goal, but this is how I would do it.
The Symbolic Toolbox normalises and simplifies your function, and puts them in descending powers of z.
syms z
f = (1+z^-1+z^-2+z^-3)/(1-(0.18*z^-1)+(0.81*z^-2))
[nf, df] = numden(f)
yields:
nf =
100*z^3 + 100*z^2 + 100*z + 100
df =
z*(100*z^2 - 18*z + 81)
tfn = sym2poly(nf)
tfd = sym2poly(df)
yield:
tfn =
100.0000e+000 100.0000e+000 100.0000e+000 100.0000e+000
tfd =
100.0000e+000 -18.0000e+000 81.0000e+000 0.0000e+000
H = tf(tfn, tfd)
yields:
H =
100 s^3 + 100 s^2 + 100 s + 100
-------------------------------
100 s^3 - 18 s^2 + 81 s
Continuous-time transfer function.
NOTE: Your code specified a discrete-time transfer function, but tf will only provide that if you specify a sampling period, Ts, in seconds (although you can set Ts to -1 to leave the sample time unspecified).
4 commentaires
Star Strider
le 28 Mai 2014
I wouldn’t consider myself an expert, but MATLAB and I go back a ways. I have my strengths, though.
The options are simply features of the Control System Toolbox functions that you can use to make your code as robust as possible.
My pleasure!
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Formula Manipulation and Simplification dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!