Is there a difference between an embedded function implementation in simulink and the m file code implementation?
显示 更早的评论
I used the embedded matlab function to implement the following code:
function [y1,y2,y3] = fcn(u,t,I,d)
%#eml
Ts=0.3;
Td=I/1000-Ts;
Ca=0.48;
u=u/Ca;
y1=d*exp(-Ts/(Ca*t)) +u*Ts;
y2=y1*exp(-Td/(Ca*t));
num1=(1/3)*y1;
num2=(2/3)*y2;
y3=num1+num2;
end
I copied these lines into a regular m file and the results did not match. (with the values I=1000,u=80.5,t=4,d is the second output y2 so i only set an initial value of 60). Although i did not set an initial value in the simulink code (don't know how) but it shouldn't matter.
I do not understand why there is a difference in the results. Thanks, Hadas
回答(1 个)
Kaustubha Govind
2013-4-5
0 个投票
类别
在 帮助中心 和 File Exchange 中查找有关 Simulink 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!