Question
Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion the motion of an object projected into the air at an
Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion the motion of an object projected into the air at an angle. The object flies in the air until the projectile returns to the horizontal axis (x-axis), where y=0. This MATLAB program should allow the user to try to hit a 2-m diameter target on the x-axis (y=0) by varying conditions, including the lunch direction, the speed of the lunch, the projectiles size, and the location of the target. Plot the parabolic trajectory of each projectile simulation. Draw dots to mark the position of the projectile at 14 second intervals. Add plot title, axis labels, and legends. Then, print computation results in the command window and analyze if the object hits the target or not. Save all simulation inputs and analyses into a permanent file.
http://www.pbslearningmedia.org/resource/hew06.sci.phys.maf.projmotion/projectile- motion/
The GUI components for this project include:
1. The MATLAB GUI window should contain the following components:
A picture of the launcher.
A picture of the projectile object.
A plot to show the parabolic trajectory of each projectile simulation.
A drop-down menu for the projectile objects selection with a minimum of six (6)
choices.
A static text box to show the selected projectile object diameter.
An edit text box for the user to input an angle in degrees.
An edit text box for the user to input initial speed in meters per second.
An edit text box for the user to input the target location. The target has a 2-m
diameter.
A push button for the user to fire the projectile.
A static text box to show the total time the object will be in the air.
A static text box to show the greatest height the object will reach.
A static text box to show the maximum horizontal distance the object will travel.
A static text box to show the target hitting result, score or miss.
Use static text boxes to label fields as needed.
Additional GUI components and functions are welcome.
The following equations may be useful:
vx =vx0 +ax t x=x0 +vx0t+12ax t2 vx2 =vx02 +2ax (xx0)
vy = vy0 + ay t y = y0 + vy0t + 12 ay t2 vy2 = vy02 + 2 ay (y y0) For projectile motion, ax = 0, ay = -g, gravity g = 9.81 m/s2
2. Program the GUI to display different projectile object picture when the user selects different projectile object using the drop-down menu. Update the object diameter in the static text box based on the object selection. For example:
Object | Diameter (m) |
Golf ball | 0.043 |
Baseball | 0.074 |
Bowling ball | 0.25 |
Football | 0.17 |
Pumpkin | 0.37 |
Piano | 2 |
3. Program the GUI to take the inputs from GUI (the edit text boxes and drop-down menu) and start compute when the push button is pressed. The computation part for Homework 4 is as same as Homework 2.
(a) Based on the initial speed and angle, compute vx0 and vy0, then compute the time it takes for the object from vy0 to reach the highest point where vy = 0, using vy = vy0 + ay t. Then, consider the velocity in the y-direction only, the object will take equal amount of time to free fall from v = 0 to v = vy0 back to the same horizontal plane. Compute the total time the object will be in the air from shooting up to dropping down when it can land back to the same horizontal plane of the launcher.
(b) Separate the total time (ttotal) the object is in the air into 100 equally spaced time
points. Compute the x and y values of each time point using x = x0 + vx0t + 12 ax t2 and y =y0+vy0t+12ay t2.
(c) Plot the projectile motion of the object in the x and y coordinates.
(d) Create another time array, starting from 0, ending at the value of the total time (ttotal), with 0.25 seconds step size. Compute the x and y values of each time point using x = x0 +vx0t+12ax t2andy=y0+vy0t+12ay t2.
(e) Plot the points that mark the position of the projectile at 14 second intervals in the same figure.
(f) We can format different lines with different line width using variables, for example:
w1=6;
w2=8;
plot(x1,y1,'Linewidth',w1)
hold on
plot(x2,y2,'Linewidth',w2)
hold off
(g) Plot a 2-meter wide target at the user specified location on the x-axis (where y=0).
(h) Add plot title, legends, and label each axis clearly. Adding additional components in the
plot is encouraged.
(i) Compute the greatest height the object will reach. Compute the maximum horizontal distance the object travels when it returns to its initial height (y=0). Print the total time for which the projectile remains in the air, the greatest height the object reaches, and the maximum horizontal distance travels in the command window. Format all values to display 2-digit behind the decimal point. Try different initial velocities and angles and confirm results with online projectile motion calculator, http://www.wolframalpha.com/widgets/view.jsp?id=a39d2fee10f85ac92b3d738589138 5e6
(j) Compute the minimum and maximum target location on the x-axis. Use the final object x-axis location and the object diameter to compute the minimum and maximum range the object can hit. Modify the display in the command window to show ranges with 2- digit after decimal points precision.
(k) Add an if..else..end statements in the program to analyze if the object will hit the target and print results in the command window for the user.
After computation, program the GUI to update the static text boxes to show the computation results.
Add logic to append the simulation user inputs and results into a file, result.txt, so that the simulation record is retained after exiting MATLAB.
(The result.txt file contains the previous simulation data and results.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started