I have a problem with ODE 45 - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# I have a problem with ODE 45

Posts: 2Member
hey Guys
i have a problem with ODE i already wrote my program but it doesnt work . who can help me
i need to use the TEMP Q and R in every single steps of ode45 and say to it to do that with these new values in the next period of time and also i need to force ode45 to run the function just one time during the period and jump out of function and start with my new values

Global TEMP R Q
dt=0.00001;
time =0:dt:0.05;
gt=linspace(0,0.05,(0.05/dt)+1);
g = gt;

for k=2:length(time)

t=time(k)
i = 1;
[t,y] = ode45(@(t,y) F(t,y,gt,g),[time(k-1) :dt:time(k)],yy0(i,:),options);
yy0(i,:)=y(end,:)
i = i+1;
plot(time(k),real(y(end,1)));

end
----------------------------------------------------
Function fx = F(t,y,gt,g)
Global TEMP R Q
g=interp1(gt,g,t);
fx = zeros(4,1);

if y(1)-y(2)< 20
R=0
Q=0
TEMP=100
Else
Q = f(last(R),last(y1),last(y2))
TEMP = f(last(R),Q)
R = f(last(T))
End

fx=R.y+cos(g)