My Step Response plot from Matlab does not match the one from Simulink
Show older comments
Hello, i am new to matlab and simulink, my homework was to design a serial PID controller in simulink and tune it. After this I had to verify the output with a mathematical approach in matlab. There step input has a step time of 1 and a value of 2, there is also a process delay of .5 seconds.
The controller and the process functions and the simulink graph are the following:


While on Matlab i wrote this code expecting to get the same ouput:
s = zpk('s')
B=tf([1],[2.3 3.2 4.5])%Process Transfer Function
D=tf([1],[2.1 1] ) %Feedback Transfer Function
A= (2.8*(1 + .39/s + .75*s))
t= 0:0.01:50;
e = exp(-1.5*s) %Process delay plus step time
z=feedback(A*B*e, D)
z_setpoint = 2*z
step(z_setpoint, t)
The output I receive from matlab is the following:

The response from simulink peaks at 2.03, while the one from Matlab does at around 2.25. The settling times are also slightly different. Am I doing something wrong on Matlab when trying to replicate the same response?
I am sorry if any of this is confusing, as i mentioned before I am new to matlab and simulink. If any clarification is needed feel free to ask.
Thank you
Accepted Answer
More Answers (1)
Paul
on 17 Mar 2025
0 votes
Hi Javier,
You might want to investigate the step size control options in Simulink. The plot looks a bit jagged, which suggests the step size might be too large, which can (but does not neccesarily) impact the accuracy of the simulation.
I think more care is needed on the Matlab side to properly model the same delays in the Simulink model, one of which is applied inside the loop and the other applied outside the loop. The delay outside the loop applies at the application of the step command. You can either change the block parameter in the Step block to apply the step at t = 0 to match the Matlab step command, our you can use one of the alternative syntaxes of step to specify the time when the step input is applied to match the Simulink model.
Categories
Find more on Classical Control Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



