Question

Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the...

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 projectile’s 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 1⁄4 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+1⁄2ax t2 vx2 =vx02 +2ax (x–x0)

vy = vy0 + ay t y = y0 + vy0t + 1⁄2 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 + 1⁄2 ax t2 and y =y0+vy0t+1⁄2ay 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+1⁄2ax t2andy=y0+vy0t+1⁄2ay t2.

(e) Plot the points that mark the position of the projectile at 1⁄4 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.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

-th handuiatbac r? launch OT

Add a comment
Know the answer?
Add Answer to:
Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MATLAB Write a user defined function for a projectile motion. If a ball is launched from...

    MATLAB Write a user defined function for a projectile motion. If a ball is launched from initial position(0,0) with a velocity v0 at angle θ, determine your horizontal and vertical position. Please plot x vs. t, y vs. t and y vs. x.

  • PROJECTILE MOTION OBJECTIVE: The purpose of this lab is to study the properties of projectile motion....

    PROJECTILE MOTION OBJECTIVE: The purpose of this lab is to study the properties of projectile motion. From the motion of a steel ball projected horizontally, the initial velocity of the ball ean be determined from the measured range. For a given initial velocity, the projectile range will be measured for various initial angles, and calculated by applying the theory for motion with constant acceleration BASIC PRINCIPLES: Projectile motion occurs when an object in a two-dimensional plane experiences motion only due...

  • EXPLORE A projectile is launched with a launch angle of 30° with respect to the horizontal...

    EXPLORE A projectile is launched with a launch angle of 30° with respect to the horizontal direction and with an initial speed of 40 m/s. (A) How do the vertical and horizontal components of the projectile's velocity vary with time? (B) How long does it remain in flight? (C) For a given launch speed, what launch angle produces the longest time of flight? CONCEPTUALIZE Consider the projectile to be a point mass that starts with an initial velocity, upward and...

  • This uses MATLAB code with plotting HW19: Plotting with plot () Due 11:59 pm Monday 1....

    This uses MATLAB code with plotting HW19: Plotting with plot () Due 11:59 pm Monday 1. (10 pts) Write a script that will produce a sine curve and a cosine curve in the same plot, 0 as shown to the right. 06 0.4 0.2 To have two sets of data in one plot, you may plot the first one, then with the command hold on", plot the other. Or, you can learn how to plot two lines with just one...

  • Could somebody help me with this question for the coding on MATLAB? Thank you Projectile Motion...

    Could somebody help me with this question for the coding on MATLAB? Thank you Projectile Motion The distance a projectile travels when fired at an angle Θ is a function of time and can be divided into horizontal distance, dVotcos(O) and the vertical distance is dy Vot sin(0)-0.5gt2. Suppose a projectile is fired at an initial velocity of 100 m/s and a launch angle of /4 radians (45°). Use ezplot to graph horizontal distance on the x -axis and vertical...

  • VBA The projectile motion equations are,x=x0+v0*cos(θ)*t, y=y0+v0*sin(θ)*t+0.5*g*t^2 where x and y are the current position at...

    VBA The projectile motion equations are,x=x0+v0*cos(θ)*t, y=y0+v0*sin(θ)*t+0.5*g*t^2 where x and y are the current position at time t, x0 and y0 are the projectile’s initial position, v0 is the projectile’s initial speed, θ is the initial firing angle of the projectile, and g is the gravitational acceleration which is -9.81 m/s2 near Earth’s surface. The user (me) will input the initial x-position (m), y-position (m), speed (m/s), the firing angle (in degrees) in cells F2-F5 on Sheet2. Create a run...

  • MATLAB, please provide code script Objective: Create a function file that animates projectile motion defined by...

    MATLAB, please provide code script Objective: Create a function file that animates projectile motion defined by the following equations in a subplot. Your function should accept user inputs of launch speed and launch angle. The output of your function will be a top subplot that displays height (y) as a function of x. The bottom subplot should display the vertical velocity while the projectile is in motion. A video of what your animation should look like is posted with this...

  • 7. Do the projectile motion General Motion with Unit Vectors and Components An object undergoes the...

    7. Do the projectile motion General Motion with Unit Vectors and Components An object undergoes the following consecutive displacements: s (2i +3j +5k)m,s2 (6i- 9j + 2k)m, and s3 (10i 8j -k)m. a) Find the resultant displacement in terms of unit vectors and components. b) State the magnitude of the resultant displacement. 2. Suppose a hiker travels 5 km southwest from their camp. Then, the hiker travels 2 km 75° north of east. a) Find the displacement of the hiker...

  • EXPLORE A projectile is launched with a launch angle of 30° with respect to the horizontal...

    EXPLORE A projectile is launched with a launch angle of 30° with respect to the horizontal direction and with an initial speed of 10 m/s. s0 (A) How do the vertical and horizontal components of the projectile's velocity vary with time? 40 35 (B) How long does it remain in flight? 25 (C) For a given launch speed, what launch angle produces the longest time of flight? 15 10 toy CONCEPTUALIZE Consider the projectile to be a point mass that...

  • GUI bouncing shapes program use this interface the out put of the program should be a jFr...

    GUI bouncing shapes program use this interface the out put of the program should be a jFrame with three buttons: “add triangle”, “add square” and “add circle” and a blank screen. when the user clicks any of these buttons the corresponding shape appears and starts bouncing around the screen. the shape of these shaoes and randomized and anytime the user clicks the button you should be able to keeping adding shapes on the screen while the previosus shape is bouncing...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT