c2d function 'zoh' method formula
69 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
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]
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]
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
H1 - H3
4 个评论
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?
更多回答(4 个)
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
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
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)))
0 个评论
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)
rlocus(g)
%|-------------------Controlador em tempo continuo-------------------|
s=tf('s');
c=1.1*((s+32.5)/(s+1.2))
%|------------------------Analise de Malha fechada Contínua-----------------------------|
gf=g*c/(1+g*c)
pole(gf)
zero(gf)
step(gf,0.5)
%|----------------------------ZOH--------------------------------|
gz=c2d(g,0.0000125,'zoh')
pole(gz)
zero(gz)
%|----------------------------Discretização--------------------------------|
cz=c2d(c,0.0000125,'tustin')
cprewarping=c2d(c,0.0000125,c2dOptions('Method','tustin','PrewarpFrequency',1))
cmpz=c2d(c,0.0000125,'matched')
%|------------------------Analise de Malha fechada discreta-----------------------------|
gfz=gz*cz/(1+gz*cz)
pole(gfz)
zero(gfz)
%|-------------------------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)
0 个评论
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)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Pole and Zero Locations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


