Is there a difference between an embedded function implementation in simulink and the m file code implementation?
Afficher commentaires plus anciens
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
Réponses (1)
Kaustubha Govind
le 5 Avr 2013
0 votes
Catégories
En savoir plus sur Simulink dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!