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

Applied Physics Department, HCMUT MATLAB Projects – Physics 1

TOPIC 1: DETERMINE THE OBJECT’S TRAJECTORY


Group information:

Member of group Student code


Phan Thanh Phước 2053356
Nguyễn Trọng Bằng 2052039
Huỳnh Ngọc Tiến 2053494
Nguyễn Phúc Nguyên Khang 2053101
1. Introduction:
We can’t answer these kinds of questions using the techniques of motion along a straight
line, in which particles moved only along a straight line. Instead, we need to extend our
descriptions of motion to two- and three-dimensional situations. We’ll still use the vector
quantities displacement, velocity, and acceleration, but now these quantities will no longer
lie along a single line. We’ll find that several important kinds of motion take place in two
dimensions only—that is, in a plane. We can describe these motions with two components
of position, velocity, and acceleration. Therefore, we can conclude the object’s trajectory
from the corresponding given qualities.
(Figure ) The path of the robotic rover showing the velocity and acceleration at t = 0.0
v 0 and ⃗
s (⃗ a 0), t = 1.0 s (⃗
v1 and ⃗
a 1), and t = 2.0 s ( ⃗v 2 and a⃗ 2).

From (Figure ), the trajectory of a moving object is the path following through the space
as a function of time or the corresponding graph in the x, y, and z coordinate plane.
2. Theory
Consider a particle that is at a point P at a certain instant. The position vector r⃗ of the
particle at this instant is a vector that goes from the origin of the coordinate system to the
Applied Physics Department, HCMUT MATLAB Projects – Physics 1

point P (Figure ). The Cartesian coordinates x, y, and z of point P are the x-, y-, and z-
components of vector r⃗ .
^ y ^j+ z k^ (position vector)
r⃗ =x i+
(Figure ) The position vector r⃗ from the origin
to point P has components x, y, and z.

The change in position (the displacement) during this interval is


∆ r⃗ =⃗
r 2−⃗ ^ ^ ^
r 1=( x 2−x 1) i+ ( y 2− y 1 ) j+( z 2−z 1) k. We define the average velocity during this
interval in the same
way we did in straight-line motion, as the displacement divided by the time interval:
r⃗2 −⃗r 1 ∆ ⃗r
v av=
⃗ = (average velocity vector)
t 2 −t 1 ∆ t

Instantaneous velocity is the limit of the average velocity as the time interval approaches
zero, and it equals the instantaneous rate of change of position with time. The key
difference is that position and instantaneous velocity are now both vectors:
∆ r⃗ d ⃗r
⃗v = lim = (instantaneous velocity vector)
∆t→0 ∆ t dt
It’s often easiest to calculate the instantaneous velocity vector using components. It follows
that the components v x , v y, and v z of the instantaneous velocity ⃗v are simply the time
derivatives of the coordinates x, y, and z. That is,
dx dy dz
v x= v y = v z= (components of instantaneous velocity)
dt dt dt
Applied Physics Department, HCMUT MATLAB Projects – Physics 1

During the time interval from to the vector change in velocity is ⃗ v 2−⃗
v 1=∆ ⃗v . We
define the average acceleration ⃗ a av of the car during this time interval as the
velocity change divided by the time interval t 2−t 1=∆ t :
v 2−⃗
⃗ v 1 ∆ ⃗v
a av =
⃗ = (average acceleration vector)
t 2−t 1 ∆t

The instantaneous acceleration is also equal to the instantaneous rate of change of velocity
with time:
∆ ⃗v d ⃗v
a⃗ = lim = (instantaneous acceleration vector)
∆t→0 ∆ t dt
Each component of the acceleration vector is the derivative of the corresponding
component of velocity:
d vx d vy d vz
a x= ay= az = (components of instantaneous acceleration)
dt dt dt
In terms of unit vectors,
d vx d v y d vz
a⃗ = ^
i+ ^j + k^
dt dt dt
Since each component of velocity is the derivative of the corresponding coordinate, we can
express the components a x , a y, and a z of the acceleration vector a⃗ as

d2 x d2 y d2 z
a x = 2 a y = 2 a z= 2
dt dt dt
The acceleration vector a⃗ itself is

d 2 x ^ d2 y ^ d 2 z ^
a⃗ = 2 i+ 2 j+ 2 k
dt dt dt
3. Plan and requirement:
Use MATLAB to solve the following problem:
"The position of the particle moving in the x, y coordinate plane is determined by the
radius vector r⃗ =x0 cos (5 t) i⃗ + y 0 cos(5 t +φ) ⃗j . Give in advance the values x 0, y 0 and φ,
determine the trajectory of the object?"
MATLAB Program Development:
Step 1. Enter the initial values (the recommended quantities).
Applied Physics Department, HCMUT MATLAB Projects – Physics 1

Step 2. Set the corresponding equations and use symbolic commands to solve the system of
equations. Then give equations of the movement of objects and conclusions about the
trajectory.
Step 3. Sketch the object's trajectory over time.
→ Using the symbolic calculation of MATLAB, we can solve mentioned differential
equations to obtain the motion equation of the object or particle, from which the necessary
features of the motion can be derived.
4. MATLAB code and explanation:
a. MATLAB code 1:
% Motion in two dimensions
% Collection of initial values
clc;clear
close all
syms t x(t) y(t)
x0 = input('Enter a value x0 = ');
y0 = input('Enter a value y0 = ');
pi = input('Enter a value pi = ');
% Setting equations

x(t) = x0*cos(5*t) %The component x of position vector in motion


y(t) = y0*cos(5*t+pi) %The component y of position vector in motion
dx = diff(x,t) %The component x of velocity vector in motion
dy = diff(y,t) %The component y of velocity vector in motion
ax=diff(x,t,2) %The component x of acceleration vector in motion
ay=diff(y,t,2) %The component y of acceleration vector in motion
% Plotting the trajectory
%Sketch the shape of trajectory in two-dimensional motion
figure
fplot(x,y)
Applied Physics Department, HCMUT MATLAB Projects – Physics 1

hold on
x_star = subs(x,t,0)
y_star = subs(y,t,0)
fplot(x_star,y_star,'*')
title ('The trajectory of the particle')
%Sketch the trajectory of position over time
figure
fplot(t,x)
hold on
fplot(t,y)
title ('The x, y coordinates of the particle')
%Sketch the trajectory of velocity over time
figure
fplot(t,dx)
hold on
fplot(t,dy)
title ('The velocity of the particle in the x, y directions')
%Sketch the trajectory of acceleration over time
figure
fplot(t,ax)
hold on
fplot(t,ay)
title ('The acceleration of the particle in the x, y directions')

The description of commands used in MATLAB code 1:


subs(s,old,new) returns a copy of s replacing all occurrences of old with new, and then
evaluating s.
hold on retains plots in the current axes so that new plots added to the axes do not delete
existing plots. 
Applied Physics Department, HCMUT MATLAB Projects – Physics 1

figure creates a new figure window using default property values. This new figure
window becomes the current figure, and it displays on top of all other figures on the
screen. 
fplot(xt,yt,tinterval) plots over the specified interval. Specify the interval as a two-
element vector of the form [tmin tmax]
fplot(___,Name,Value) specifies line properties using one or more Name,Value pair
arguments. Name,Value pair settings apply to all the lines plotted.

b. MATLAB code 2:
%Collection of initial values
ti = input('Initial value of time = ')
tf = input('Final value of time = ')
x0 = input('Amplitude of first cosine = ')
y0 = input('Amplitude of second cosine = ')
pi = input('Initial phase of second cosine')
%Setting equations
t = ti : 0.01 : tf
rx = x0*cos(5.*t)
ry = y0*cos(5.*t + pi)
%Plotting the trajectory
figure(1)
plot(rx, ry)
xlabel('X-axis')
ylabel('Y-axis')
figure(2)
plot3(rx, ry, t)
xlabel('X-axis')
ylabel('Y-axis')
zlabel('Time')

The description of commands used in MATLAB code 2:


Applied Physics Department, HCMUT MATLAB Projects – Physics 1

plot(X,Y) creates a 2-D line plot of the data in Y versus the corresponding values in X.
plot3(X1,Y1,Z1,...), where X1, Y1, Z1 are vectors or matrices, plots one or more lines in
three-dimensional space through the points whose coordinates are the elements
of X1, Y1, and Z1.
figure(h) does one of the following: If h is the handle or the Number property value of an
existing figure, then figure(h) makes that existing figure the current figure, makes it
visible, and moves it on top of all other figures on the screen. The current figure is the
target for graphics output.
xlabel(str) labels the x-axis of the current axes with the text specified by str. Reissuing
the xlabel command replaces the old label with the new label.

5. Results and Discussion:


a. MATLAB code 1: Example. The position of the particle moving in the x, y coordinate
plane is determined by the radius vector r⃗ =x0 cos (5 t) i⃗ + y 0 cos(5 t +φ) ⃗j . Give in advance the
values x 0=1, y 0=2 and φ=120 rad, determine the trajectory of the object?
Applied Physics Department, HCMUT MATLAB Projects – Physics 1

b. MATLAB code 2: Example. The position of the particle moving in the x, y coordinate
plane is determined by the radius vector r⃗ =x0 cos (5 t) i⃗ + y 0 cos(5 t +φ) ⃗j . Give in advance the
values x 0=1, y 0=2 t i=0, t f =5 and φ=120 rad, determine the trajectory of the object?

→ Above results exactly match the results manually calculated. With MATLAB calculation,
we can replace appropriately many others values of quantities to study other special cases.
5. Conclusion:
The project has completed the solution of determining the trajectory of a moving object
problem using MATLAB symbolic calculation. With this tool we can solve more complex
motion situations that cannot be solved by the analytical method.
References:
University Physics of Modern Physics 13th edition by Hugh D. Young and Roger A.
Freedman
-The end-

You might also like