- 4

- 0

I believed the two plots should be exactly the same but they are not! I am very disappointed and confused! can someone explain why they are not the same? and if t2 and F2 are not the actual values after each step, how can I obtain actual values of variable (t) and function (F) after each step?

many thanks in advance,

Ashkan

function tdelay

clear

clc

global Fd ts i F2 t2

Fd=8;

F0=5;

ts=0.01;

i=1;

% F=(F0-Fd)*exp(-t./ts)+Fd;

[t,F]=ode45(@werely,[0 1],F0);

plot(t,F)

hold on

plot(t2,F2,'r')

end

function dF=werely(t,F)

global ts Fd i t2 F2

t2(i)=t;

F2(i)=F;

dF=(1/ts)*(-F+Fd);

i=i+1;

end