How To Plot A Projectile Motion Using Mat Lab (Penn State Students)
How To Plot A Projectile Motion Using Mat Lab (Penn State Students)
This will provide a helpful description for the user and now you will
start describing the variables you will be using
Step 4: List the variables
Using a note form, list the variables that you will use to calculate and plot
the projectile motion.
Type the following:
%List of Variables:
% v_initial is used to represent the initial velocity of the shot in m/s
% theta is used to represent the varies angles between 0 and pi/2 in radians
% range is used to represent the range (height) of an object at varies
% angels in meters
% g is used to represent the value of gravity, g=9.81 m/s^2
% air resistance is neglected
This detailed list of variables will provide an easier understanding
for the user of each variable meaning.
Step 5: Insert initialization and calculations
Starting from this step every command is mandatory to plot the projectile
motion.
1. Write the initialization in a command form under Variable initialization:
%Variable Intialization:
v_initial=input('Please enter a value for the initial velocity of the object in
m/s >> ');
Command Structure:
input is a command that allows the user to insert a certain value for the
variable
Parenthesis should follow the command
Apostrophes indicate the comment that will show up later in the
command field when running the script.
Fig. 4:
Run
icon
In the command window, you will be asked to insert a value for the
initial velocity
(Fig. 5).
Fig. 5: Input field
3. Insert 10 as a
value for the initial velocity (any other number is acceptable)
In the command window a description of the plot will appear (Fig.
6).
Also, the
plot of the
projectile
motion will
appear in an
external
box.