Is there a difference between an embedded function implementation in simulink and the m file code implementation?
Show older comments
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
Answers (1)
Kaustubha Govind
on 5 Apr 2013
0 votes
Categories
Find more on Simulink in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!