MatLab wont let me use Ax as a variable?

3 views (last 30 days)
Hi,
Im currently doing a university assignment about a packaged falling from a helicopter with drag force.
The problem I have is that matlab wont let me use the variable Ax, it lets me use A, AX, x, Axx, but when I use Ax i get an error message in my dsolve line. Whats going on??
%MOTION OF PACKAGE.
%Constant boundary conditions
syms Vx
m=265; %Mass of package [kg]
g=9.81; %Acceleration due to gravity [ms^-2]
p=1.225; %Air density at sea level [kgm^-3].
%Boundary conditions parachute closed (0-3 seconds).
Axx=1; %Area facing horizontal air flow.
Cdx=1.3; %Horizontal drag coefficient.
%Create time row vectors for when parachure is open and closed.
t1=linspace(0,3,31); %Time 0-3 seconds (0.1 second steps).
%Equations to define motion of package (F=ma ODE).
eqn1 = '(0.5*p*Axx*Cdx)*Vx^2=m*DVx'; %x-axis velocity
%Solution for x-axis velocity when parachute is closed.
inits1 = 'Vx(0)=14.3053'; %Boundary condition, when t=0 seconds, Vx=32mph.
Vx1=dsolve(eqn1,inits1,'t1'); %Solve ODE using boundry conditions so that Vx1 is a function of t1.
Vx1=eval(vectorize(Vx1)); %Evaluate solution Vx1 for all values of t1, create row vector of results.
  2 Comments
Star Strider
Star Strider on 15 Dec 2017
Where are you using ‘Ax’ it in your code? I don’t see it in what you posted.
What is the complete error message (all the red text in your Command Window)?
Kristian Thompson
Kristian Thompson on 15 Dec 2017
Hi, I sorry if I did not make that clear. Where I have used Axx on line 11, I am wanting to use Ax. However I get the dsolve line wont work when the variable i called Ax, yet it works when I change it to AX or Axx
The full error message is below:
Error using symengine The operand is invalid.
Error in mupadengine/evalin (line 111) res = mupadmex(statement,output_type{:});
Error in dsolve>mupadDsolve (line 335) sys = [sys_sym evalin(symengine, sys_str)];
Error in dsolve (line 193) sol = mupadDsolve(args, options);
Error in stepbystep (line 34) Vx1=dsolve(eqn1,inits1,'t1'); %Solve ODE using boundry conditions so that Vx1 is a function of t1.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 15 Dec 2017
syms Vx(t)
m = 265; %Mass of package [kg]
g = 9.81; %Acceleration due to gravity [ms^-2]
p = 1.225; %Air density at sea level [kgm^-3].
%Boundary conditions parachute closed (0-3 seconds).
Axx = 1; %Area facing horizontal air flow.
Cdx = 1.3; %Horizontal drag coefficient.
%Create time row vectors for when parachute is open and closed.
t1 = linspace(0,3,31); %Time 0-3 seconds (0.1 second steps).
DVx = diff(Vx);
%Equations to define motion of package (F=ma ODE).
eqn1 = (0.5*p*Axx*Cdx)*Vx^2==m*DVx; %x-axis velocity
%Solution for x-axis velocity when parachute is closed.
inits1 = Vx(0)==14.3053; %Boundary condition, when t=0 seconds, Vx=32mph.
Vx1sol = dsolve(eqn1, inits1); %Solve ODE using boundry conditions so that Vx1 is a function of t
Vx1 = double(subs(Vx1sol, t, t1));
plot(t1, Vx1)
  3 Comments
Walter Roberson
Walter Roberson on 15 Dec 2017
In your code you are attempting to pass a string to dsolve() to operate on. When you pass a string to the symbolic routines (other than str2sym()) then the code in the string is expected to be in MuPAD programming language, not in MATLAB programming language. It just happens to be the case that in MuPAD programming langue, Ax is expected to be followed by :: and then the name of a category. So, you just cannot do what you want to do.
The fix is to either use a different variable name (like you found), or else do not pass strings to the symbolic routines (like my solution.)
Kristian Thompson
Kristian Thompson on 15 Dec 2017
Thanks so much for your help! This really confused me, I had copied the solution that I had made for the y axis motion where I used the variable Ay, which worked fine. Thanks for your quick reply and clear explanation!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!