Plotting the ODE without an analytical solution
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Steven Lord
2020-5-25
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!