Differential eguations: modify the program

조회 수: 1 (최근 30일)
jixie zhuangbei
jixie zhuangbei 2015년 4월 2일
댓글: Torsten 2015년 4월 7일
Differential eguations
dy1/dt=-a*y1+y2*y3
dy2/dt=-b(y2-y3)
dy3/dt=-a*y2+ y3-3*y2*y3
a=4 b=8 c=30
y1(0)=0
y2(0)=0
y3(0)=10-10 =0.0000000001
MATLAB ODE45_main:
tspan=[0,100];
y0=[0; 0;10^(-10)];
[t,y]=ode45('ODE45_fun',tspan,y0);
data=[t,y];
save ODE45_data.txt data –ascii
plot3(y(:,1), y(:,2), y(:,3))
grid on
MATLAB ODE45_fun:
function dy=ODE45_fun(t,y)
a=4; b=18; c=30;
dy(1)=-a*y(1)+y(2)*y(3);
dy(2)=-b*(y(2)-2*y(3));
dy(3)=c*y(2)-y(3)-3*y(2)*y(1);
dy=[dy(1);dy(2);dy(3)];
The program can work without any error. If the formula for y4:
y4=-3*y2*y3-4*y1*y3+8*y1*y3
How can I modify the program? And the curve of y4 ?

채택된 답변

Torsten
Torsten 2015년 4월 2일
tspan=[0,100];
y0=[0; 0;10^(-10);0];
M=[1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 0];
options=odeset('Mass',M);
[t,y]=ode45(@ODE45_fun,tspan,y0,options);
function dy=ODE45_fun(t,y)
a=4; b=18; c=30;
dy(1)=-a*y(1)+y(2)*y(3);
dy(2)=-b*(y(2)-2*y(3));
dy(3)=c*y(2)-y(3)-3*y(2)*y(1);
dy(4)=y(4)-(-3*y(2)*y(3)-4*y(1)*y(3)+8*y(1)*y(3));
dy=[dy(1);dy(2);dy(3);dy(4)];
Best wishes
Torsten.
  댓글 수: 2
jixie zhuangbei
jixie zhuangbei 2015년 4월 3일
MATLAB 7
In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 328 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 337 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 324 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 325 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 326 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 327 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 328 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 337 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 324 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 325 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 326 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 327 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 328 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 337 In ODE45_main at 8 Warning: Matrix is singular to working precision. > In funfun\private\odemassexplicit>ExplicitSolverHandleMass1 at 38 In ode45 at 324 In ODE45_main at 8 .....................................
Torsten
Torsten 2015년 4월 7일
I see now that ODE45 can not handle a singular mass matrix.
Use ODE15S instead.
Best wishes
Torsten.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by