Plotting the ODE without an analytical solution
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Joo Seo Lee
le 25 Mai 2020
Réponse apportée : Steven Lord
le 25 Mai 2020
How do I plot the equation
d^2(x)/dt^2=0.002cos(x-t)-sin(x)
where x(0)=0.2 and x'(0)=0 for t=0:100?
I asked the question before, but the graph that was plotted was starting from x(0)=0
the answer I got before was
dfun = @(t, x) [x(2); 0.002*cos(x(1)-t)-sin(x(1))];
time = [0 100];
ic = [0; 0];
[t, x] = ode15s(dfun, time, ic);
plot(t, x);
legend({'x', 'xdot'})
0 commentaires
Réponse acceptée
Steven Lord
le 25 Mai 2020
If your initial conditions are supposed to be: "where x(0)=0.2 and x'(0)=0 for t=0:100?" why are you specifying them as x(0) = 0 and x'(0) = 0?
ic = [0; 0];
Instead specify your desired initial conditions.
ic = [0.2; 0];
0 commentaires
Plus de réponses (0)
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!