R (T) Sin T I+cost J+T K T 0: Vectors

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Vectors:

Consider the motion of a particle represented in vector form by r ( t )=sin t i+cos t j+ t 2 k between
the time instants t=0 to 8 π. Compute the velocity and acceleration vectors. Visualize the motion
of this particle by plotting all the three vectors in a single plot.

d
The velocity vector is given by, v ( t )= r (t)
dt
d
The acceleration vector is given by, a ( t )= v (t)
dt
T T
dx 2 dy 2 dz 2
Length of the curve is given by, s=∫ ‖v ( t)‖dt=∫
0 0 √( dt)( )( )
+
dt
+
dt
dt

d T d T /dt v(t)
Curvature is defined by, κ= = , where T =
ds ds /dt ‖v(t)‖

MATLAB code

clear; clc;

%%
p=@(x) [sin(x),cos(x),x*x];

%%
syms x;
velocity=diff(p(x),x)
vel=matlabFunction(velocity);
acceleration=diff(velocity,x)
acc=matlabFunction(acceleration);
%%
time_start=0;
time_end=4*2*pi;
n=30;
dtime=(time_end-time_start)/n;

%%
i=0;

for t=time_start:dtime:time_end
i=i+1;

pos=p(t);
x(i)=pos(1);
y(i)=pos(2);
z(i)=pos(3);

vel=eval(subs(velocity,t));
vx(i)=vel(1);
vy(i)=vel(2);
vz(i)=vel(3);
velmag(i)=sqrt(vx(i)^2+vy(i)^2+vz(i)^2);

a=acc(t);
ax(i)=a(1);
ay(i)=a(2);
az(i)=a(3);
accmag(i)=sqrt(ax(i)^2+ay(i)^2+az(i)^2);
end

f=matlabFunction(sqrt(dot(velocity,velocity)))
length=integral(f,time_start,time_end)

%%
hold on;
plot3(x,y,z,'-o');
q=quiver3(x,y,z,vx,vy,vz,'r')
q.MaxHeadSize=0.001;
q.AutoScaleFactor=0.1;
quiver3(x,y,z,ax,ay,az,0.003,'b')
axis vis3d

You might also like