Get difference equation from continuous transfer function

조회 수: 10 (최근 30일)
ANDREA
ANDREA 2024년 12월 22일
댓글: Star Strider 2024년 12월 22일
Hello,
I have a continuous transfer function such as:
0.002174 s + 0.0001581
----------------------------------------------------------
6.267 s^4 + 3.378 s^3 + 0.6042 s^2 + 0.04081 s + 0.0007907
I'm trying to convert it to a difference equation with negative exponents(z^(-n)).
I've already tried to calculate it manually with syms but, i found it quite impossible to work with.
tustin =(2/Ts)*(1-z^(-1))/(1+z^(-1))
modello_disc = subs(modello, s, tustin)%this is just an example. i gotta split num and den before cause it gives me an error if i try it with the tf above.
i've also tried to use the common c2d command but it doesn't give me the result i hope for.
z = tf('z', 'Variable','z^-1')
modello = tf(c2d(modello, Ts, 'tustin'))

채택된 답변

Star Strider
Star Strider 2024년 12월 22일
One approach —
0.002174 s + 0.0001581
----------------------------------------------------------
6.267 s^4 + 3.378 s^3 + 0.6042 s^2 + 0.04081 s + 0.0007907
s = tf('s');
Hs = (0.002174*s + 0.0001581) / (6.267*s^4 + 3.378*s^3 + 0.6042*s^2 + 0.04081*s + 0.0007907)
Hs = 0.002174 s + 0.0001581 ---------------------------------------------------------- 6.267 s^4 + 3.378 s^3 + 0.6042 s^2 + 0.04081 s + 0.0007907 Continuous-time transfer function.
Ts = 1;
Hz = c2d(Hs, Ts, 'tustin')
Hz = 3.472e-05 z^4 + 7.187e-05 z^3 + 7.308e-06 z^2 - 6.213e-05 z - 3.228e-05 ----------------------------------------------------------------------- z^4 - 3.505 z^3 + 4.598 z^2 - 2.675 z + 0.5823 Sample time: 1 seconds Discrete-time transfer function.
Hz.Variable = 'z^-1'
Hz = 3.472e-05 + 7.187e-05 z^-1 + 7.308e-06 z^-2 - 6.213e-05 z^-3 - 3.228e-05 z^-4 ----------------------------------------------------------------------------- 1 - 3.505 z^-1 + 4.598 z^-2 - 2.675 z^-3 + 0.5823 z^-4 Sample time: 1 seconds Discrete-time transfer function.
Other options are available. See c2dOptions for details.
.
  댓글 수: 2
ANDREA
ANDREA 2024년 12월 22일
Thank you really much! You just saved me hours of wasting time with the syms library.
Just a quick question, why wouldn't my script before with
z = tf('z', 'Variable','z^-1')
Am i not doing the same thing but in a general way?
Star Strider
Star Strider 2024년 12월 22일
My pleasure!
That would work if you defined your transfer function in the ‘z’ domain. (See Discrete-Time Transfer Function Model Using Rational Expression for those details.) It will not automatically convert a continuous to a discrete transfer function. You need to do that similarly to the way I did here.
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by