Error in ode45 (line 115)

2 次查看(过去 30 天)
Edward
Edward 2021-1-21
评论: Edward 2021-1-21
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
Walter Roberson 2021-1-21
ode45 can never be used for symbolic expressions. See dsolve() instead, or see the first example for odeFunction
  3 个评论
Walter Roberson
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
Edward 2021-1-21
Okay, thank you so much for the help!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Equation Solving 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by