Error using dsolve for three second-order differential equations
5 views (last 30 days)
Show older comments
I am trying to use dsolve to solve three differential equations of motion. They are all second order differential equations.
However, I am receiving the following error message:
--------------------------
Error using mupadengine/feval_internal
No differential equations found. Specify differential equations by using symbolic functions.
Error in dsolve>mupadDsolve (line 341)
T = feval_internal(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 210)
sol = mupadDsolve(args, options);
Error in basicEOM (line 65)
S = dsolve(odes,conds)
---------------------------
My full code is as follows:
-------------------------------
clc,clear
% 2 dimensional equations of motion for a quadcopter/drone
% neglecting air resistance, wind, other fluid dynamic implications, thermal implications, and complex geometric
% features
syms x(t) y(t) theta(t) thetaDot(t) thetaDDot(t) xDot(t) xDDot(t) yDot(t) yDDot(t) %x y and theta are the generalized coordinates. Three DOF system
g = -9.81; % accel due to gravity on Earth.
% alpha is the angle of the arm w.r.t. the body from the horizontal on the
% body
%beta is the angle between the two arms above the body --> 180 - 2*alpha
%Fl and Fr are the left and right thrust forces
% M is the mass of the body and I2 is the MOI of the body
% m is the mass of one arm and I1 is the MOI of one arm. L is the length of
% the arms
% assigning some basic values:
alpha = 25; %degrees
beta = 180 - 2*alpha;
Fl = 1;
Fr = 1;
M = 2;
m = 1;
I1 = 1;
I2 = 1;
L = 0.3;
thetaDot(t) == diff(theta(t),t);
thetaDDot(t) == diff(theta(t),t,2);
xDot == diff(x(t),t);
xDDot(t) == diff(x(t),t,2);
yDot(t) == diff(y(t),t);
yDDot(t) == diff(y(t),t,2);
%equations of motion derived from langrage's equations:
ode1 = (I2 + 2*I1)*thetaDDot(t) - m*g*L/2 *(cosd(alpha+theta(t))) + cosd(beta+theta(t)+alpha) - (Fr-Fl)*cosd(alpha) == 0;
ode2 = (M+2*m)*xDDot(t) - (Fr+Fl)*sind(theta(t)) == 0;
ode3 = yDDot(t) + g - (Fr+Fl)*cosd(theta(t))/(M+2*m) == 0;
odes = [ode1;ode2;ode3];
%initial conditions
cond1 = theta(0) == 0;
cond2 = x(0) == 0;
cond3 = y(0) == 0;
cond4 = thetaDot(0) == 0;
cond5 = xDot(0) == 0;
cond6 = yDot(0) == 0;
conds = [cond1 cond2 cond3 cond4 cond5 cond6];
S = dsolve(odes,conds)
Thank
0 Comments
Answers (1)
Ameer Hamza
on 17 Apr 2020
There are a few issues in your code. Compare the following code with your code to find the current syntax of symbolic declaring ODEs in MATLAB
clc,clear
% 2 dimensional equations of motion for a quadcopter/drone
% neglecting air resistance, wind, other fluid dynamic implications, thermal implications, and complex geometric
% features
syms x(t) y(t) theta(t) %x y and theta are the generalized coordinates. Three DOF system
g = -9.81; % accel due to gravity on Earth.
% alpha is the angle of the arm w.r.t. the body from the horizontal on the
% body
%beta is the angle between the two arms above the body --> 180 - 2*alpha
%Fl and Fr are the left and right thrust forces
% M is the mass of the body and I2 is the MOI of the body
% m is the mass of one arm and I1 is the MOI of one arm. L is the length of
% the arms
% assigning some basic values:
alpha = 25; %degrees
beta = 180 - 2*alpha;
Fl = 1;
Fr = 1;
M = 2;
m = 1;
I1 = 1;
I2 = 1;
L = 0.3;
thetaDot(t) = diff(theta(t),t);
thetaDDot(t) = diff(theta(t),t,2);
xDot(t) = diff(x(t),t);
xDDot(t) = diff(x(t),t,2);
yDot(t) = diff(y(t),t);
yDDot(t) = diff(y(t),t,2);
%equations of motion derived from langrage's equations:
ode1 = (I2 + 2*I1)*thetaDDot(t) - m*g*L/2 *(cosd(alpha+theta(t))) + cosd(beta+theta(t)+alpha) - (Fr-Fl)*cosd(alpha) == 0;
ode2 = (M+2*m)*xDDot(t) - (Fr+Fl)*sind(theta(t)) == 0;
ode3 = yDDot(t) + g - (Fr+Fl)*cosd(theta(t))/(M+2*m) == 0;
odes = [ode1;ode2;ode3];
%initial conditions
cond1 = theta(0) == 0;
cond2 = x(0) == 0;
cond3 = y(0) == 0;
cond4 = thetaDot(0) == 0;
cond5 = xDot(0) == 0;
cond6 = yDot(0) == 0;
conds = [cond1 cond2 cond3 cond4 cond5 cond6];
S = dsolve(odes,conds)
However, MATLAB symbolic engine is taking too much time to solve this equation. I eventually terminated the execution after some time without getting any answer. If time is an issue, I recommend using a numerical solver, e.g., ode45.
0 Comments
See Also
Categories
Find more on Equation Solving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!