Error in ode45 (line 115)

5 views (last 30 days)
Edward
Edward on 21 Jan 2021
Commented: Edward on 21 Jan 2021
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!

Answers (1)

Walter Roberson
Walter Roberson on 21 Jan 2021
ode45 can never be used for symbolic expressions. See dsolve() instead, or see the first example for odeFunction
  3 Comments
Walter Roberson
Walter Roberson on 21 Jan 2021
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 on 21 Jan 2021
Okay, thank you so much for the help!

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!