how can i Solve this equation With ode45
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
(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
0 Kommentare
Antworten (1)
Star Strider
am 15 Jan. 2020
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!