Why discrete transfer function show different result in Simulink but same result in Matlab?
6 次查看(过去 30 天)
显示 更早的评论
I am getting different results in Matlab & Simulink when I try to simulate step response of a discrete spring mass damper transfer function. Here is my transfer function.
H=tf([1],[1 0.2 1]); %transfer function of a continuous system
Hd=c2d(H,0.01) %converting continuous system to a discrete system with sampling time of 0.01
Hd = 4.997e-05z +4.993e-05
-----------------------
z^2 - 1.998 z + 0.998
step(H,'-',Hd,'r--')
When I plot this in Matlab I get the same trajectory for both continuous and discrete system which is as expected .
Figure(1): Matlab result
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197722/image.png)
The issue is when I try to do the same in Simulink, I get different result for the discrete system.
I made two changes to my Simulink settings in Model Configuration parameters:
1) I changed the solver selection from variable step to Fixed-Step
2) Fixed-Step size(Fundamental sample time) to 0.01. Everything else is kept as default
Figure(2): Simulink Model
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197723/image.png)
-
Figure(3): Simulink Result
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197725/image.png)
I don't understand what am I doing wrong in Simulink? I am expecting a trajectory similar to a continuous system
Thank you,
0 个评论
回答(3 个)
ONT
2020-5-12
Hello,
The cause of this issue is that the discrete transfer function you have in Discrete Transfer Function Simulink block is not the same as the one that MATLAB calculated with c2d function.
The coefficents of Hd(z) after using c2d function on H(s) are:
for Numerator
0 4.99662669945566e-05 4.99329671410653e-05
for Denominator
1 -1.99790209943320 0.998001998667333
In your Simulink Discrete Transfer Function you rounded up the coefficents and therfore changed the dynamic behaviour of system.
If you retype the coefficents from MATLAB to Simulink exactly as they are, the step responses will align in Simulink just like in MATLAB. Same if instead of hand-typing the coefficents into Transfer Function block, you will use LTI System Block and reference H and Hd LTI objects from MATLAB workspace.
1 个评论
Suyash Jadhav
2022-1-14
编辑:Suyash Jadhav
2022-1-14
This is the right solution for the issue. If you see your response rising, make sure the pole at denominator is <1.
Steve Lee
2019-3-14
I had a same problem, why it so different even I had checked carefully all sample times.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!