How does Simulink Simulate Transfer function?
4 views (last 30 days)
Show older comments
Nicobari Jarawa
on 5 Nov 2015
Edited: Nicobari Jarawa
on 5 Nov 2015
Hi, I was working with Transfer Functions in Simulink and am seeing some weird results. The transfer function I am trying to simulate is tf([2 4],[1 4]). Now if I convert the same transfer function into state space I will get A=-4, B=1, C=-4, D=2 such that Xdot=A*X+B*u and Y=C*X+D*u. Just because I want to understand how everything works I am using a matlab user defined function in simulink to calculate my output of the transfer function, I am usimg X(t)=X(t-1)+dt*(A*X(t-1)+B*u(t)) and then Y=C*X(t)+D*u(t) where Y is my output. The simulink model is shown in picture
And the code inside user define MATLAB function is as follows
function y = fcn(u)
dt=0.01;
persistent X
if isempty(X)
X=0;
end
b0=2;b1=4;a1=4;D=b0;
Beta1=b1-D*a1;
X=X + dt*(-a1*X+u);Y=Beta1*X-D*u;
% X=X+dt*(2*udash+u-4*X);
y = Y;
When I run simulation the output of two blocks are not same it looks something like
Where Yellow color is for the Transfer Fcn block. What am I doing wrong. I will appreciate any help regarding this matter. I am using ODE 1 solver with fixed time step of 0.01.
Regards, TM
0 Comments
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!