Equation of 3D motion with V, An, R

3 views (last 30 days)
Luyen Tran
Luyen Tran on 28 Dec 2020
Commented: Alan Stevens on 28 Dec 2020
Hello masters! I have an equation of x, y. Calculate the velocities in x(vx) and y(vy). Continue to calculate the acceleration in x(ax) and y(ay). Calculate velocity magnitude (v), acceleration magnitude (a), tangential acceleration magnitude (at), normal acceleration magnitude (an), curvature radius (R) over time from 0 to 5s . And finally draw the trajectory. However I had some trouble writing matlab code and didn't know how to draw trajectory.
function ptcd_ptqd
clc
clear var1
clear var2
close all
%% Input
t = linspace(0,5,6);
%% Calculate coordinates
x = 3*t.^2-(4/3*t.^3) ;
y = 8*t ;
dt = diff(t);
dx = diff(x);
dy = diff(y);
%% Calculate velocity magnitude
vx = dx./dt ;
v = sqrt(vx.^2+vy.^2);
dvx = diff(vx);
dvy = diff(vy);
%% Calculate acceleration magnitude
ax = dvx./dt;
a = sqrt(ax.^2+ay.^2);
end

Answers (1)

Alan Stevens
Alan Stevens on 28 Dec 2020
A little more like this perhaps, since you are given explicit expressions for velocities and accelerations (though note that ax should be 6 - 8t, not 6 - 4t):
x = @(t) 3*t.^2 - 4*t.^3/3;
vx = @(t) 6*t - 4*t.^2;
ax = @(t) 6 - 8*t;
y = @(t) 8*t;
vy = @(t) 8;
ay = @(t) 0;
t = linspace(0,5,100);
v = sqrt(vx(t).^2 + vy(t).^2);
a = sqrt(ax(t).^2 + ay(t).^2);
at = abs(diff(v)./diff(t));
an = sqrt(abs(a(1:end-1).^2 - at.^2));
R = v(1:end-1).^2./an;
plot(x(t),y(t)),grid
xlabel('x'),ylabel('y')
  2 Comments
Luyen Tran
Luyen Tran on 28 Dec 2020
Thanks Alan Stevens! but I was given only x and y equations
Alan Stevens
Alan Stevens on 28 Dec 2020
Ok, but they are simple to differentiate. Instead of defining x, y etc as functions, you could specify the values of t first, then simply calculate corresponding values of x, y etc, using diff for the derivatives. Note that each time you use diff, you reduce the length of the vector by 1.

Sign in to comment.

Categories

Find more on Simulation, Tuning, and Visualization 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!