How to extract transfer function coefficient from symbolic functions?

10 visualizaciones (últimos 30 días)
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)?

Respuesta aceptada

Star Strider
Star Strider el 26 de Mayo de 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.
After that, the numden function is your friend here:
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)
then sym2poly:
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
then create your transfer function with tf:
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 comentarios
Diamond
Diamond el 28 de Mayo de 2014
you sound so expert about this, sir. on the contrary, this is my first matlab project. haha
got it. i think i will try those options. thanks again.
Star Strider
Star Strider el 28 de Mayo de 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!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Formula Manipulation and Simplification 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