How many times the program is run?

%%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

David Sanchez
David Sanchez 2015년 3월 17일
"How many times the program is run?"
What program, the number of the for-loop iterations?
Lan
Lan 2015년 3월 18일
편집: Lan 2015년 3월 18일
yes, the number of the for-loop iterations. How to set up the program ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2015년 3월 17일
편집: Jan 2015년 3월 17일

0 개 추천

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.

카테고리

태그

아직 태그를 입력하지 않았습니다.

질문:

Lan
2015년 3월 17일

편집:

Lan
2015년 3월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by