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

1. Open MATLAB 2. Create a Function file named Lab05 (a) Right click Current Fol

ID: 3585245 • Letter: 1

Question

1. Open MATLAB 2. Create a Function file named Lab05 (a) Right click Current Folder title of that window (b) Select New File by moving mouse to that option (c) Click on Function in the pop-up menu (d) Type Lab05 in the highlight field and hit the enter key 3. Double click the Lab05.m enter (that you just created) in the Current Folder window 4. The horizontal displacement of an object shot at an angle of with respect to the x-axis and an initial velocity of v is given by: Modify the Function file so that it: (a) Takes both v (m/s) and (radians) as input (b) Calculates the horizontal displacement of a projectile shot at the given initial velocity and angle • if v > 0 and (0 /2) then the horizontal displacement is computed as defined above • otherwise the horizontal displacement is defined to be zero (c) Returns this calculated horizontal displacement as output 5. Call your numerous times (with different values for v and ) to make sure that it is computing correct resulting horizontal displacements each time. 6. Create a vector of angle that are with in your functions range angs = 0:0.125:1.5; 7. Create a second vector of the resulting displacements (with v fixed at 100) disps = Lab05(100, angs);

Explanation / Answer

% matlab function.

function [dis] = lab05(v,angs)
len = size(angs);
dis = zeros(1,len(:,2));
for i = 1:len(:,2)
if (v > 0 && (rad >= 0 && rad <= pi/2))
dis(:,i) = ((v*v)/9.8)*sin(radtodeg(angs(:,i)));
else
dis(:,i) = 0;
end
end
end


% v and radian from user
prompt = 'enter velocity ';
v = input(prompt);
prompt = 'enter angle in radian ';
angs = input(prompt);
res = lab05(v,angs)

% fixed v
v = 100;
angs = 0.0:0.125:1.5;
res = lab05(v,angs)