How to solve a double complex ode using ode45 in MATLAB
조회 수: 6 (최근 30일)
표시 이전 댓글
The odes are:
ode(1) = diff(x,t) == (sqrt(1+x^2)*y)/(x*(t^2));
ode(2) = diff(y,t) == (x^3)*(t^2);
given x(0)=infty; y(0)=0.
I want to draw two picture to reflect x^3(u)-y relation and the u axis should be drawn by log(u) scale.
댓글 수: 0
채택된 답변
Walter Roberson
2021년 10월 16일
The infinite boundary condition is a problem for symbolic solution: dsolve() rejects it.
The 0 initial time is a problem: you divide by time, so you generate a numeric infinity at the initial time, which numeric solvers cannot recover from.
If you set initial time above 0, and set the boundary condition to be finite, then you get a singularity. The time of singularity depends upon the boundary condition you set -- with the failure time being approximately 1 over the boundary condition.
syms x(t) y(t)
dx = diff(x)
dy = diff(y)
odes = [dx == (sqrt(1+x^2)*y)/(x*(t^2));
dy == (x^3)*(t^2)]
ic = [x(0) == 1e8, y(0) == 0]
sol = dsolve(odes, ic)
[eqs,vars] = reduceDifferentialOrder(odes,[x(t), y(t)])
[M,F] = massMatrixForm(eqs,vars)
f = M\F
odefun = odeFunction(f,vars)
xy0 = double(rhs(ic))
tspan = [1e-50 100]
[t, xy] = ode45(odefun, tspan, xy0);
figure
semilogy(t, xy(:,1), 'k+-')
title('x')
figure
plot(t, xy(:,2), 'k*-')
title('y')
추가 답변 (1개)
Cris LaPierre
2021년 10월 16일
You can solve a symbolic ODE with initial/boundary conditions using dsolve
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!