How do i transform a second grade ODE into coordinates?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nicolae Lungu
el 18 de En. de 2021
Editada: James Tursa
el 22 de En. de 2021
Hello,
I'm new to matlab and i'm quite struggling with it.
I have been assigned a coursework in which i must find the trajectory of a projectile.Within it there is a second order ODE which i must transform into x&y's in order to get a system of first-order equations.
The second order equation is: r''(t) = (1 /m)* (((− 1 /2 )*ρ*cd*A*|r'|*r' )− mg );
Mathematically, this system will be expressed a:
y' = F(t, y(t))=dy/dt,
where: y(t) = [vx(t), vy(t), rx(t), ry(t)]
Is there any way to accomplish that in matlab and could anyone give suggestions with examples on how to do so?
Thanks!
0 comentarios
Respuesta aceptada
James Tursa
el 19 de En. de 2021
Editada: James Tursa
el 19 de En. de 2021
Looks like motion is restricted to be on the x-y plane, so r is 2D. You have a 2nd order ODE in a 2D frame, so that means you have a 2 * 2 = 4th order system of 1st order equations. Define the following:
r = [x;y]
From that define a state vector consisting of all the variables and derivatives up to but not including the highest order:
Y = [x;y;xdot;ydot]
Then the derivative of your state vector is
Ydot = d/dt [x;y;xdot;ydot] = [xdot;ydot;xdotdot;ydotdot] = [Y(3);Y(4);xdotdot;ydotdot]
So then you simply need to get the expressions for xdotdot and ydotdot. You do this by rewriting your rdotdot equation above in terms of x and y using the definition r = [x;y]. You do that by replacing the following
r' = d/dt r = d/dt [x;y] = [xdot;ydot] = [Y(3);Y(4)]
Thus
|r'| = norm([Y(3);Y(4)])
That being said, you are missing something on the -mg term. This is a vector equation so you need to attach a vector direction for this. I would assume this should be in the y direction (vertical).
So write a derivative function or function handle that takes in a 4-element Y vector and outputs the Ydot vector.
12 comentarios
James Tursa
el 22 de En. de 2021
Editada: James Tursa
el 22 de En. de 2021
Why do you keep putting code in where I tell you to delete it? Why do you keep using variables such as tdotdot and ydotdot that don't exist?
Delete this code completely:
ydot(1) = y(3); % d (x coordinate)/dt = dx/dt
ydot(2) = y(4); % d (y coordinate)/dt = dy/dt
ydot(3) = tdotdot;
ydot(4) = ydotdot;
and put this line back the way it was:
rdot = [y(3);y(4)];
And then the output is in x,y,xdot,ydot order, so change to this:
rx = oput(:,1); %Position coordinates for x axis
ry = oput(:,2); %Position coordinates for y axis
vx = oput(:,3); %Velocity coordinates for x axis
vy = oput(:,4); %Velocity coordinates for y axis
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!