Using ODE45 to solve a system of 2nd order ODEs equation

조회 수: 4 (최근 30일)
Missael Hernandez
Missael Hernandez 2020년 5월 6일
댓글: Missael Hernandez 2020년 5월 6일
I am trying to solve
This is what I have written as my finction script. everytime I try to solve it once I type the initial condiitions to the Command Windown, I get "Show complete stack trace." How can I solve my problem?
function theta_dot = pendulum(t,x)
theta_dot = [x(2);
-8.8*x(1)-1.8*x(3);
x(4);
1.8*x(1)+8.8*x(3)];
end

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2020년 5월 6일
After fixing the sign-errors in your ODE-function this:
thetathetadot0 = [0 0 0 -1];
[t,theta] = ode45(@(t,y) pendulum(t,y),0:0.1:10,thetathetadot0);
plot(t,theta)
works just fine.
HTH
  댓글 수: 2
Missael Hernandez
Missael Hernandez 2020년 5월 6일
I get:
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in rg5y (line 2)
[t,theta] = ode45(@(t,y) pendulum(t,y),0:0.1:10,thetathetadot0); - Show complete stack trace
Missael Hernandez
Missael Hernandez 2020년 5월 6일
fixed it! thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by