How does Simulink Simulate Transfer function?

3 ビュー (過去 30 日間)
Nicobari Jarawa
Nicobari Jarawa 2015 年 11 月 5 日
編集済み: Nicobari Jarawa 2015 年 11 月 5 日
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

採用された回答

Nicobari Jarawa
Nicobari Jarawa 2015 年 11 月 5 日
Got it, my output equation should be
Y=Beta1*X+D*u;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by