how can i Solve this equation With ode45
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
(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 commentaires
Réponses (1)
Star Strider
le 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 commentaires
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!