0% found this document useful (0 votes)
16 views2 pages

Iismavo CW Matlab

The document provides instructions for creating a MATLAB script that simulates projectile motion. The script should: 1) Ask the user for launch parameters and calculate initial velocity components. 2) Calculate the time for the projectile to hit the ground. 3) Simulate the motion over 1000 time steps using kinematic equations to find displacement. 4) Plot the trajectory and report time of flight and horizontal distance to the user. The script can optionally be extended to a GUI.

Uploaded by

hibimilos01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Iismavo CW Matlab

The document provides instructions for creating a MATLAB script that simulates projectile motion. The script should: 1) Ask the user for launch parameters and calculate initial velocity components. 2) Calculate the time for the projectile to hit the ground. 3) Simulate the motion over 1000 time steps using kinematic equations to find displacement. 4) Plot the trajectory and report time of flight and horizontal distance to the user. The script can optionally be extended to a GUI.

Uploaded by

hibimilos01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MATLAB

COURSEWORK
(Optional)

Projectile Motion Simulator


Task: Create a script that produces a graphical simulation of the motion of a projectile.
Make sure your code is readable and executable. Make sure you explain, either in the code (using
comments) or in a separate note, all the variables that you will be using.

Submission
Firstname_Lastname_MP.m

Procedure

1. Ask the user for the height of the launching point 𝐻, initial velocity 𝑈, and the angle of
projectile motion 𝑇𝑒𝑡𝑎.

2. Calculate the velocity vector in the vertical 𝑈𝑦 and horizontal 𝑈𝑥 direction through equations

𝑈𝑦 = 𝑈 sin(𝑇𝑒𝑡𝑎)

𝑈𝑥 = 𝑈 cos(𝑇𝑒𝑡𝑎)

3. Calculate the time 𝑇 when an object hits the ground. At this time, vertical displacement 𝑆𝑦 = 0 (see the
illustration) or mathematically can be written as
1
𝑔𝑇2 + 𝑈 𝑇 + 𝐻 = 0
𝑦
2
Therefore, the time when an object hits the ground 𝑇 can be obtained by solving the quadratic equations
above. Hint: You only need the positive value of 𝑇.

4. Create time array 𝑡 = [0, … , 𝑇] with 1000 elements using linspace function
𝑡 = 𝑙𝑖𝑛𝑠𝑝𝑎𝑐𝑒(0, 𝑇, 1000)

5. Apply the SUVAT equations to calculate the object’s displacement (ignore the air resistance) in the
vertical 𝑆𝑦 and horizontal 𝑆𝑥 direction through equations

1
2
𝑆𝑦 = 𝑈𝑦𝑡 + 𝑔𝑡 + 𝐻
2
𝑆 𝑥 = 𝑆 𝑥𝑡

with 𝑔 = −9.81 (do not forget to use dot multiplication .*).

6. Plot the trajectory of the object.

7. Communicate the time of flight of the object to the user as well as the total horizontal distance
travelled in the Command Window.

8 (Extension). Create a GUI of your Projectile Motion Simulator.

You might also like