Same Function but Different Result (Basic Function)
Show older comments
Hi all, can anybody help me ? I have 2 same functions here, but when I evaluate them, I got a slightly different result. Perhaps someone could help me to check it ? Thank you
The first version is
t = [4:1:14];
A0 = 23
rho = 1.2
Ton = 1.2
Toff = 6
r = 0.6
del_a = 3.8
del_m = 0.1
p = t>=Ton;
q = t <Toff;
s = t>=Toff;
A = (A0*exp(rho.*(t - Ton)).*p.*q) + (A0*exp(rho*(Toff - Ton))*exp(-(r+del_a).*(t - Toff))).*s;
M = ((r/(r+del_a - del_m))*(A0*exp(rho*(Toff - Ton))*exp(-del_m.*(t-Toff)) - A)).*s;
y = A+M
plot(t,y)
and the second version is :
t = [4:1:14];
Par(1) = 23
Par(2) = 1.2
Par(3) = 1.2
Par(4) = 6
Par(5) = 0.6
Par(6) = 3.8
Par(7) = 0.1
model = @(Par,t) ( ( Par(1)*exp(Par(2).*(t - Par(3))).*(t>=Par(3)).*(t < Par(4)) )...
+ ( Par(1)*exp(Par(4) - Par(3))*exp(-(Par(5)+Par(6)).*(t - Par(4))).*(t >= Par(:,4)))...
+ ( (Par(5)/(Par(5) + Par(6) - Par(7))) *( (Par(1)*exp(Par(2)*(Par(4) - Par(3))))* ...
exp(-Par(7).*(t - Par(4))) - (( Par(1)*exp(Par(2).*(t - Par(3))).*(t>=Par(3)).*(t < Par(4)) )...
+ ( Par(1)*exp(Par(4) - Par(3))*exp(-(Par(5)+Par(6)).*(t - Par(4))).*(t >= Par(4)))...
) ) ).*(t>=Par(4)) ...
)
y = model(Par,time);
plot(t,y)
the problem is I have a slightly different result, but both of them are a same function. Can anybody help ? What I want to do is to convert my function in the first version into a function handle like in the second version
Thanks very much
1 Comment
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!