How do I solve this equation?
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
Ameer Hamza
el 23 de Mayo de 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'})
Categorías
Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!