Question: Note: The subject is Matlab... clc clear close all global g theta g = 9.8; % m/s^2 - acceleration due to gravity theta = 60;

Note: The subject is Matlab...

clc

clear

close all global g theta

g = 9.8; % m/s^2 - acceleration due to gravity theta = 60; Vo_arr = [60 80]; % m/s

for k =1:length(Vo_arr) Vo = Vo_arr(k);

% Compute intial velocity components Voy = Vo*sind(theta); Vox = Vo*cosd(theta);

% Computation of the time, tmax to attain maximum height tmax = Voy/g;

% Total flight time = ttol =2*tmax ttot = 2*tmax;

% Computation of maximium height hmax = (Voy)^2/(2*g);

% Let us compute the range, R of the projectile R = (Vox^2)*(sind(2*theta))/g;

% Generate arrays % The time array tarr = 0:0.002:ttot; % the instantaneous height and x arrays harr = Voy *tarr - 0.5 * g* tarr .^2; xarr = Vox *tarr;

% Plots plot(xarr,harr) hold on; grid on; end legend('60','80')

%%%%%%%

Test the script by running it (click on run). It will display a trajectory for a projectile launched at 60

o

with

speed array, Vo_arr of 60 and 80 m/s. This is for you to see the trend.

You will break up the script into two User-defined functions.

Using the script, create

(a). User-defined function that computes and outputs R, ttot, Vox and Voy using the speed, Vo as the

only input.

theta

and

g

are the only global variables. No other global variable should be declared. Note

that R stands for the range and ttot is the total time of flight.

(b). User-defined function that computes harr and xarr and plots(xarr, harr) using Vox,Voy and ttot as the

only input variables. This function should have no output

(d). Write a script that calls these two functions. Use for loops for 4 different Runs of the script for Vo =

70, 80, 100 and 125 m/s. These values should be supplied to the script via the keyboard using the input

command. Using legend label your plots. The plots should be on one figure which you should declare as

Figure 3

(e). Modify your program to use subplot to show each of the above plots on one page. Name the figure as

figure 4

.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!