Plotting the ODE without an analytical solution
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Steven Lord
on 25 May 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 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!