How do I eliminate error when plotting 2D system of DEs with sinusoidal functions?
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!