MATLAB Answers


Controller design - transfer function producing different response from numerical model

Asked by Murray
on 31 Oct 2012
I'm producing different results when I use built-in Simulink blocks such as Transfer Function and PID Controller as compared to explicitly describing the system using Derivative, Integrator, Sum blocks etc. I believe it has something to do with the way MATLAB linearises the models in Simulink and other tools like SISOTool.
As an example, I have a simple linear model of the form
x'' = u/1.54
with u as the input and x as the state. Applying a PD controller to this:
u = (2 + 5*s)*e
gives the closed loop TF
x(s)/r(s) = (5*s + 2) / (1.54*s^2 + 5*s + 2)
Comparing the response of this TF to a step input to the explicitly stated model produces different outputs, as seen in the images. Does anyone know the cause of this? They should be identical, but MATLAB seems to be solving one model incorrectly. To reiterate, I get the first response when using PID Control or Transfer Functions blocks or the MATLAB functions "Step" and SISOTool. The second response is obtained from the model with the double integrator.


Sign in to comment.

1 Answer

Answer by Arkadiy Turevskiy on 31 Oct 2012
Edited by Arkadiy Turevskiy on 2 Nov 2012
 Accepted Answer

I agree with the recommendation not to use pure derivative from the previous answer. Derivative block is causing problems in the simulation. To implement a PD controller in real life, you wouldn't use pure derivative anyway. Real signals are always noisy, and pure derivative amplifies high frequency noise.
Use a PID Controller block from Continuous library instead. Set I gain to zero. You can make N (filter coefficient) very high if you want to closely approximate pure derivative. If you look under block mask you will see the block implements a derivative action using an integrator. This is exactly what the doc for derivative block recommends.
If you do that, and also add a gain of 1/1.54 (looks like you forgot it in the lower branch of your model), you will get the same results.
Also easy to do in MATLAB:


Thanks for the answer, seems to make sense using the integrator for derivative action. Do you have any suggestion as to how rate feedback would be used in the controller, rather than derivative action on the error? I found using rate feedback produced the same response as using the derivative block.
Thanks, Murray
You can use the rate feedback, but if you go through derivations (or linearize a model in Simulink), you will see the transfer function you end up with is 2 / (1.54*s^2 + 5*s + 2). It does not have a zero in the numerator. The step response you get is correct, it is indeed close to, but not exactly the same as what you get from your second branch in your Simulink model.
Your other comment about not wanting to use built-in PID Block - you do not have to. I was simply suggesting you look under mask to see how derivative is implemented there using basic Simulink blocks.
In other words, in your Simulink model, replace the derivative block by a feedback loop with an integrator in the feedback path and a gain of say 100 in the forward path. That gives you a transfer function of s*100/(s+100) which provides derivative action at low frequencies but attenuates high frequency noise.
You then get "correct" simulation results.
Hope this helps.

Sign in to comment.