c2d function 'zoh' method formula

조회 수: 65 (최근 30일)
Tamas Toth-K
Tamas Toth-K 2020년 10월 4일
답변: raphael antunes 2022년 10월 14일
Hi!
My following question would be, say i have a continuous time PI controller:
and i apply the function c2d(,,'zoh'), then it appears that matlab uses he substitution:
.
Which is completly fine, however if i have a transfer function like:
then when applying the c2d function c2d(,,'zoh'), it appears that the previous substitution in this case changes (s!=(z-1)/Ts)depending on the value of . I would like to know why Matlab does this, and what is its algebraic formula if possible?
Thank you!

채택된 답변

Paul
Paul 2020년 10월 4일
편집: Paul 2022년 4월 11일
I suspect that in your first case for C the substitution you cite is only applicable because of the form of C. In general, the ZOH approximation does not use that substitution. Though probably not implemented this way, the genaral form for the ZOH approximation can be implemented as shown below, and compared to what Matlab produces
P=5;Ti=6;Ts=.1; % example data
C=tf(P*[Ti 1],[Ti 0]);
Cz=c2d(C,Ts,'zoh');
Cznew = minreal(c2d(C*tf(1,[1 0]),Ts,'impulse')*tf([1 -1],[1 0],Ts)/Ts);
[Cz Cznew]
ans = From input 1 to output: 5 z - 4.917 ----------- z - 1 From input 2 to output: 5 z - 4.917 ----------- z - 1 Sample time: 0.1 seconds Discrete-time transfer function.
R=10;Te = 5; W=tf(1,[R*Te 1]);
Wz=c2d(W,Ts,'zoh');
Wznew = minreal(c2d(W*tf(1,[1 0]),Ts,'impulse')*tf([1 -1],[1 0],Ts)/Ts);
[Wz Wznew]
ans = From input 1 to output: 0.001998 --------- z - 0.998 From input 2 to output: 0.001998 --------- z - 0.998 Sample time: 0.1 seconds Discrete-time transfer function.
The substitution you cite, s = (z -1)/Ts, the forward rectangular rule, which appears to be an allowable, albeit undocumented, method input to c2d.
Edit: The forward rectangular rule is not implemented. When specifying the method input as a character string, only the first character matters, so 'forward' is actually 'foh'
H = tf(1,[1 1 1]);
Ts = 0.1;
H1 = c2d(H,Ts,'foh');
H2 = c2d(H,Ts,'forward');
H3 = c2d(H,Ts,'fu');
H1 - H2
ans = 0 Static gain.
H1 - H3
ans = 0 Static gain.
  댓글 수: 4
Paul
Paul 2020년 10월 7일
I don't know anything about Mathematica, but it seems to give the same results as Matlab as far as I can tell. Using the example on this page:
sys=tf([1 0],[1 1 1]);
sysd=c2d(sys,0.4,'tustin')
sysd =
0.1613 z^2 - 0.1613
----------------------
z^2 - 1.548 z + 0.6774
Sample time: 0.4 seconds
Discrete-time transfer function.
Note that Mathematica doesn't scale the coeffiecient of z^2 to unity. So multiply the top and bottom to match the Mathematica result:
>> sysd.num{:} = sysd.num{:}*4.96;sysd.den{:} = sysd.den{:}*4.96;
>> sysd
sysd =
0.8 z^2 - 0.8
------------------------
4.96 z^2 - 7.68 z + 3.36
Sample time: 0.4 seconds
Discrete-time transfer function.
Which is the same as the Mathematica result for Tustin (or blinear). Now do the same for ZOH:
>> sysd=c2d(sys,0.4,'zoh')
sysd =
0.321 z - 0.321
---------------------
z^2 - 1.54 z + 0.6703
Sample time: 0.4 seconds
Discrete-time transfer function.
Which is the same as the Mathematica result. Can you show an example where Mathemeatica and Matlab give different results?
In Matlab, c2d supports several methods. The 'impulse' method is the z-transform of the samples of the continuous time impulse response of the system. Based on its doc page, it appears that Mathematica does not support the 'impulse' method.
What exactly are you trying to do?
Tamas Toth-K
Tamas Toth-K 2020년 10월 7일
Thank you, very much! after you said it is he same I took another look and realized that out of the many substituted variables one was incorrect, after the fix it is the same :)

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

추가 답변 (4개)

raphael antunes
raphael antunes 2022년 10월 3일
n=1.501877347e+06;
d=[1 4.255319149e+03 125.1564456e0+03];
g=tf(n,d)
gz=c2d(g,0.000369,'zoh')
pole(gz)
zero(gz)
  댓글 수: 1
Paul
Paul 2022년 10월 3일
If this Answer is supposed to be a new Question, I suggest deleting this answer and posting a new Question (with more detail on what the question actually is, in addition to the code).

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


raphael antunes
raphael antunes 2022년 10월 4일
n=1.502e+06;
d=[1 4.255e+03 125.1e+03];
g=tf(n,d)
gz=c2d(g,0.0000125,'zoh')
z=tf('z');
c=(z-0.9998)/(z-1)
step(feedback(gz*c/(1+gz*c)))

raphael antunes
raphael antunes 2022년 10월 4일
%|----------------Função de transferência em tempo continuo----------|
n=1.502e+06;
d=[1 4.255e+03 125.1e+03];
g=tf(n,d)
g = 1.502e06 --------------------- s^2 + 4255 s + 125100 Continuous-time transfer function.
rlocus(g)
%|-------------------Controlador em tempo continuo-------------------|
s=tf('s');
c=1.1*((s+32.5)/(s+1.2))
c = 1.1 s + 35.75 ------------- s + 1.2 Continuous-time transfer function.
%|------------------------Analise de Malha fechada Contínua-----------------------------|
gf=g*c/(1+g*c)
gf = 1.652e06 s^4 + 7.086e09 s^3 + 4.437e11 s^2 + 7.24e12 s + 8.061e12 ----------------------------------------------------------------------------------- s^6 + 8512 s^5 + 2.003e07 s^4 + 8.194e09 s^3 + 4.619e11 s^2 + 7.279e12 s + 8.083e12 Continuous-time transfer function.
pole(gf)
ans = 6×1
1.0e+03 * -4.2254 -3.7896 -0.4338 -0.0328 -0.0296 -0.0012
zero(gf)
ans = 4×1
1.0e+03 * -4.2254 -0.0325 -0.0296 -0.0012
step(gf,0.5)
%|----------------------------ZOH--------------------------------|
gz=c2d(g,0.0000125,'zoh')
gz = 0.0001153 z + 0.0001133 ----------------------- z^2 - 1.948 z + 0.9482 Sample time: 1.25e-05 seconds Discrete-time transfer function.
pole(gz)
ans = 2×1
0.9996 0.9486
zero(gz)
ans = -0.9824
%|----------------------------Discretização--------------------------------|
cz=c2d(c,0.0000125,'tustin')
cz = 1.1 z - 1.1 ----------- z - 1 Sample time: 1.25e-05 seconds Discrete-time transfer function.
cprewarping=c2d(c,0.0000125,c2dOptions('Method','tustin','PrewarpFrequency',1))
cprewarping = 1.1 z - 1.1 ----------- z - 1 Sample time: 1.25e-05 seconds Discrete-time transfer function.
cmpz=c2d(c,0.0000125,'matched')
cmpz = 1.1 z - 1.1 ----------- z - 1 Sample time: 1.25e-05 seconds Discrete-time transfer function.
%|------------------------Analise de Malha fechada discreta-----------------------------|
gfz=gz*cz/(1+gz*cz)
gfz = 0.0001268 z^5 - 0.0003761 z^4 + 0.0002492 z^3 + 0.0002407 z^2 - 0.0003587 z + 0.0001181 --------------------------------------------------------------------------------------- z^6 - 5.896 z^5 + 14.48 z^4 - 18.97 z^3 + 13.98 z^2 - 5.493 z + 0.8992 Sample time: 1.25e-05 seconds Discrete-time transfer function.
pole(gfz)
ans =
1.0002 + 0.0000i 0.9995 + 0.0004i 0.9995 - 0.0004i 0.9946 + 0.0000i 0.9539 + 0.0000i 0.9486 + 0.0000i
zero(gfz)
ans = 5×1
-0.9824 1.0000 0.9996 0.9996 0.9486
%|-------------------------Resposta ao degrau (aproximações discretas)------------------|
step(feedback(cmpz*gz,1),'r',0.5)
hold on
step(feedback(cprewarping*gz,1),'b',0.5)
step(feedback(cmpz*gz,1),'G',0.5)
legend('Tustin','Tustin prewarping ','MPZ')
%|-------------------------continuo x discreto----------------------------|
step(feedback(cmpz*gz,1),'r',0.5)
hold on
step(gf,'b',0.5)
step(feedback(cmpz*gz,1),'r',0.05)
hold on
step(gf,'b',0.05)

raphael antunes
raphael antunes 2022년 10월 14일
n=-20.27;
d=[1 0 -66.93];
g=tf(n,d)
s=tf('s');
pi1=1.3*s+6;
g1f=feedback(-13.05*g,pi1)
aux=(-0.1628*s^2+9.81)/s^2
pi2=0.8*s+0.7;
g2f=feedback(pi2*g1f*aux,1)
step(g2f)

카테고리

Help CenterFile Exchange에서 Pole and Zero Locations에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by