フィルターのクリア

how can i Solve this equation With ode45

1 回表示 (過去 30 日間)
adem ski
adem ski 2020 年 1 月 15 日
回答済み: Star Strider 2020 年 1 月 15 日
(d2y/dt^2)+w=0
how can i Solve this equation With ode45, w=1 and intrevall [0 10] and
y(1)=2
y(2)=0

回答 (1 件)

Star Strider
Star Strider 2020 年 1 月 15 日
Try this:
syms y(t) w T Y
DE = diff(y,2) + w;
[VF,Subs] = odeToVectorField(DE)
ODEfcn = matlabFunction(VF, 'Vars',{T,Y,w})
w = 1;
tspan = [0 10];
ic = [2 0];
[t,y] = ode45(@(t,y)ODEfcn(t,y,w), tspan, ic);
figure
plot(t,y)
grid
legend(string(Subs))
I assume the ‘y(1)’ and ‘y(2)’ references are to the initial conditions. If they are boundary conditions, a different approach is required.

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by