W(0)=0; W(f)=2.8; d(P)/d(W)=((-0.3743)/(2*P))*(1-(0.15*X)); P(0)=1; d(X)/d(W)=0.5*((0.08*(0.75*(1-X)))/(1-(0.15*X))); X(0)=0; Trying to solve these two ODEs

 채택된 답변

Star Strider
Star Strider 2018년 10월 24일

1 개 추천

Try this:
PX_ODE = @(W,PX) [((-0.3743)./(2*PX(1))).*(1-(0.15*PX(2))); 0.5*((0.08*(0.75*(1-PX(2))))./(1-(0.15*PX(2))))];
[W,PX] = ode15s(PX_ODE, [0, 2.8], [1; 0]);
figure
plot(W, PX)
grid
Here ‘P’ is ‘PX(1)’, ‘X’ is ‘PX(2)’. The system encounters a singularity at 2.67, and the integration stops.

댓글 수: 5

Kurt
Kurt 2018년 10월 24일
Is there another way to better show both equations
Star Strider
Star Strider 2018년 10월 24일
Show them in what sense?
Plotting them is the only way I can think of.
Kurt
Kurt 2018년 10월 24일
I mean to keep them in their original forms
Kurt
Kurt 2018년 10월 24일
I was trying to do it this way, syms P(W) X(W) eqn1 = diff(P, W) == ((-0.3743)/(2*P))*(1-(0.15*X)); eqn2 = diff(X, W) == (0.5*((0.08*(0.75*(1-X)))/(1-(0.15*X))));
[odes, vars] = odeToVectorField(eqn1, eqn2); fun = matlabFunction(odes,'Vars',{'t','Y'}); X0(0) = [0, 0]; tspan = [0, 2.8]; [t, sol] = ode45(fun,tspan,x0);
P = sol(:,2); X = sol(:,1);
Star Strider
Star Strider 2018년 10월 24일
That certainly works, although ‘P(0)’ cannot be zero. If ‘X(0)’ is greater than 1, the system will integrate out to 2.8.
Also, ‘fun’ is essentially the same as my code, and the result is the same. (The system is ‘stiff’, so ode15s or another stiff solver is more appropriate.)

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

추가 답변 (0개)

카테고리

제품

릴리스

R2018b

질문:

2018년 10월 24일

댓글:

2018년 10월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by