How do I eliminate error when plotting 2D system of DEs with sinusoidal functions?
Mostra commenti meno recenti
I'm trying to plot the trajectories of an unforced and undamped pendulum in phase space at various initial conditions. I've got a system defined by:
function dY = undf(t,Y)
th = Y(1);
om = Y(2);
dY(1) = om;
dY(2) = -9.81*sin(th)/0.1;
dY = [dY(1);dY(2)];
end
I'm then using Matlab's ode45 function to calculate om(ega) and th(eta) on a set time interval at a given initial condition. I got good plots for initial conditions (0,0), (0.01,0), and (pi,0). For (pi,0), I used sym(pi) to get rid of round off error. My issue now is that when plotting from the I.C. (3,0), Matlab seems to be rounding off the values of th and om. This gives me a bad plot. I assume this is because sin(3) is an irrational number. However, when I try another I.C., such as (12,0), I get a good plot. Any ideas on how to fix this?
Thanks,
Axel
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!