how can i Solve this equation With ode45

1 次查看(过去 30 天)
(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 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