Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Solve in MATLAB Problem 1: Snowball Throw Write an M-file program to show the tr

ID: 2074858 • Letter: S

Question

Solve in MATLAB

Problem 1: Snowball Throw Write an M-file program to show the trajectory of a thrown snowball. Your file should prompt the user to enter the initial velocity in feet per second and the angle in degrees. The goal of the user is to hit the hat of a person five feet tall and fifty feet away To show the hat (target), plot a point at (50,5), e.g., plot (distance,height, 50,5,'rs', 'MarkerSize',7) This will plot the hat shaped as a red square. You may need to alter the marker size according to what you think looks good. On the x-axis of the plot, vary the message depending on the following situations . "Wow a hit!" if within 0.1 feet of hat. . "Close" if within 1 foot of hat. * "Too far!" if snowball overshoots by more than a foot . "Too short!" if snowball falls short by more than a foot. These are all based on measurements in the vertical direction At the end of your code, print (nicely formatted) two sets of initial velocity and angle that will hit the hat. Note that you solved a similar problem for Lab 3, so you can look back at those calculations. Here are some other hints 1. This problem is posed in US Customary units, so use g-32.2 ft/s, and the initial velocity will be in fts 2. Calculate t hit and use a time step of t hit/100. 3. You need the x-distance traveled, which is equal to the initial velocity multiplied by the time (i.e there is no acceleration in the horizontal direction) It is unlikely that your distance vector will contain the number "50" exactly. Examine the built-in interpolation function in MATLAB interp1 for this 4. 5. Use an if statement to select the proper xlabel depending on the four conditions. You may add any extra feedback that you wish. Ignore any error message you get about the labeling of the x- axis 6. To make the plot have equal scales on both axes, use axis ('equal')

Explanation / Answer

clc
clear all
close all
g=32.2;
x=50;
u=input('initial velocity in ft/sec');
th=input('angle in degrees');
t=x/(u*cosd(th));
t_hit=0:t/100:t;
y1= (u*sind(th)*t_hit)-(0.5*g*t_hit.^2);
x1= t_hit.*(u*cosd(th));
plot(50,5,'rs','markersize',7)
hold on
plot(x1,y1)
ylabel('height')
if y1(end)>=4.09 && y1(end)<=5.01
xlabel('Wow a hit')
elseif y1(end)>=4 && y1(end)<=6
xlabel('Close')
elseif y1(end)>6
xlabel('Too far!')
else y1(end)<4
xlabel('Too short')
end
axis equal
% initial velocity and angle which will hit hat
iv=[42 60];
an=[42 60];

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote