How many times the program is run?
8 views (last 30 days)
Show older comments
%%ODE45_fun解方程
tspan=[0,1e-5];
x0=[2.1e+10,1,1,1,1];
[t,x]=ode45('ODE45_fun',tspan,x0);
a1=1;a2=1;e1=9;e2=7;f1=56;f2=98;g1=76;g2=665;
a=a1+a2; e=e1+e2; f=f1+f2; g=g1+g2;
[n,m]=size(x);
for i=1:n
x(i,6)=x(i,4)*x(i,5)+x(i,2)*x(i,3)+e*f+e*g;
end
data=[t,x];
save ODE45_data.txt data -ascii
subplot(2,3,1),plot(t,x(1))
subplot(2,3,2),plot(t,x(2))
subplot(2,3,3),plot(t,x(3))
subplot(2,3,4),plot(t,x(4))
subplot(2,3,5),plot(t,x(5))
subplot(2,3,6),plot(t,x(6))
Warning: Failure at t=1.075809e-007. Unable to meet integration tolerances
without reducing the step size below the smallest value allowed (2.117582e-022) at
time t. > In ode45 at 355
2 Comments
David Sanchez
on 17 Mar 2015
"How many times the program is run?"
What program, the number of the for-loop iterations?
Answers (1)
Jan
on 17 Mar 2015
Edited: Jan
on 17 Mar 2015
The problem appears in the function ODE45_fun, which you did not provide. If the step size is smaller than 2.11e-22 numerical instabilities will rule the solution. Therefore ODE45 decides to stop the integration, which is much better than replying a false result.
It seem like there is an instability or jump in the function at this time. We could take a look into it, when you post the relevant code.
By the way: Providing the function to be integrated as string is a very old method. Prefer function handles like @ODE45_fun.
0 Comments
See Also
Categories
Find more on Logical 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!