How do I solve this equation?
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Ameer Hamza
2020년 5월 23일
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'})
카테고리
도움말 센터 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!