Error in ode45 (line 115)
이전 댓글 표시
I'm trying to solve a second-order ODE and am receiving the following errors:
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0,
options, varargin);
Error in code (line 17)
[out1,out2] = ode45(ode,[0 100],cond);
Here's my code:
syms phi(t) theta(t)
phid(t) = diff(phi,t);
thetad(t) = diff(theta,t);
q(t) = [phi(t);theta(t)];
qd(t) = diff(q,t);
qdd(t)= diff(qd,t);
a = 10;
b = 3;
y = 2;
d = 5;
M = [a+b*(sin(theta))^2 y*cos(theta);y*cos(theta) b];
C = [b*thetad*sin(theta)*cos(theta) -y*thetad*sin(theta)+b*phid*sin(theta);-b*phid*sin(theta) 0];
G = [0;-d*sin(theta)];
ode = 0 == M*qdd+C*qd+G;
cond = [q(0)==[1;-1], qd(0)==[0;0]];
[out1,out2] = ode45(ode,[0 100],cond);
I'm not very experienced with Matlab, so I apologize if this is an obvious mistake I'm making.
Thank you in advance!
답변 (1개)
Walter Roberson
2021년 1월 21일
0 개 추천
ode45 can never be used for symbolic expressions. See dsolve() instead, or see the first example for odeFunction
댓글 수: 3
Edward
2021년 1월 21일
Walter Roberson
2021년 1월 21일
That is not an error, that is a warning that dsolve does not know how to solve that system. Either dsolve does not have the algorithm for that system, or else there is no closed form solution for the system, or else the system is inconsistent for closed form.
You should follow the guidance in odeFunction first example.
Edward
2021년 1월 21일
카테고리
도움말 센터 및 File Exchange에서 Equation Solving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!