How do I solve this equation?
Show older comments
The given equation is
d^2(x)/dt^2=0.002cos(x-t)-sin(x)
I tried to solve it by
for t=0:100
dsolve('D2x==0.002*cos(x-t)-sin(x)','x(0)==0,Dx(0)==0')
end
plot(x,t)
but it doesn't work
Accepted Answer
More Answers (1)
Ameer Hamza
on 23 May 2020
You ode does not seem to have an analytical solution (at least dsolve() is not able to find a solution). You can try a numerical solver, e.g., ode45. See this example for second-order ODE.: https://www.mathworks.com/help/matlab/ref/ode45.html#bu3uj8b. This is the code for your equation
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'})
Categories
Find more on Symbolic Math Toolbox 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!