Solve nonlinear 2nd order ODE numerically

2 ビュー (過去 30 日間)
Lucas
Lucas 2022 年 7 月 28 日
コメント済み: MOSLI KARIM 2022 年 8 月 12 日
I need to solve the following nonlinear 2nd order ODE, that is, find such that
1-x=-\frac{y''(x)}{(1+(y'(x))^2)^{{3/2}}
I tried using
>> syms y(x)
>> ode = -diff(y,x,2)/(1+(diff(y,x))^2)^(3/2) == 1-x;
>> ySol(x) = dsolve(ode)
but it doesn't work since apparently there is no anaylitical solution (if I rearrange the terms it does find a system of complex solutions, but I think the it is not right).
Isn't there a command to solve ODEs numerically? I am expeting something like the family of plots from here https://www.wolframalpha.com/input?i=f%27%27%28t%29%2F%28%281%2B%28f%27%28t%29%29%5E2%29%5E%283%2F2%29%29+%3D+-%281-0.25t%29
Many thanks oin advance!
  2 件のコメント
Torsten
Torsten 2022 年 7 月 28 日
What are your initial/boundary conditions for y ?
Lucas
Lucas 2022 年 7 月 29 日
My idea was to screen these conditions to find one that satisfies my problem.

サインインしてコメントする。

採用された回答

Sam Chak
Sam Chak 2022 年 7 月 28 日
You can follow the example here
and try something like this:
tspan = [0 1.15];
y0 = [1 0]; % initial condition
[t,y] = ode45(@(t, y) odefcn(t, y), tspan, y0);
plot(t, y(:,1)), grid on, xlabel('t')
function dydt = odefcn(t, y)
dydt = zeros(2,1);
c = 0.25;
dydt(1) = y(2);
dydt(2) = - (1 - c*t)*(1 + y(2)^2)^(3/2);
end
  1 件のコメント
Lucas
Lucas 2022 年 7 月 29 日
That worked, thanks!

サインインしてコメントする。

その他の回答 (2 件)

James Tursa
James Tursa 2022 年 7 月 28 日

MOSLI KARIM
MOSLI KARIM 2022 年 8 月 12 日
function pvb_pr13
tspan=[0 1.5];
y0=[1 0];
[x,y]=ode45(@fct,tspan,y0);
figure(1)
hold on
plot(x,y(:,1),'r-')
grid on
function yp=fct(x,y)
c=0.25;
yp=[y(2);-(1-c*x)*((1+(y(2))^2)^(3/2))];
end
end
  1 件のコメント
MOSLI KARIM
MOSLI KARIM 2022 年 8 月 12 日
you can used this code for solved your problem

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by