STEPS TO RUN THE CODE
-COPY THE CODE
-OPEN MATLAB AND THEN CREATE NEW SCRIPT
-PASTE THIS CODE THERE AND CHECK FOR FORMATTING ERRORS AND RUN IT
-A GRAPH WILL BE DISPLAYED SHOWING THE REQUIRED DIAGRAM
- X AND Y VALUES FOR DIFFERENT TIMES WILL BE DISPLAYED IN COMMAND WINDOW(NOT REQ FOR SOLUTION, GIVEN FOR UNDERSTANDING)
CODE
%%%%%%%%%%%%%%SECTION 1-INITIALIZATION OF VALUES%%%%%%%%%%%%%%%%%%%%%%%
syms xnew ynew
colorstring='kgbry'; %TO GIVE COLOUR
H=3; %initial height ,inft
alpha=60; %Angle OF WALL INCLINATION in DEGREES
g=32.174; %gravitational acceleration in ft/s^2
vo=25;
e=0.9;
dt=0.01;
t=0;
%SECTION2-CALCULATION OF INITIAL VELOCITIES AND POSITION OF THE PROJECTILE%
vt=vo*(sind(90-alpha));
vn=vo*e*(cosd(90-alpha));
vxo=vn*(cosd(90-alpha))-vt*(sind(90-alpha));
vyo=vn*(sind(90-alpha))+vt*(cosd(90-alpha));
x=H/tand(alpha);
X=H/tand(alpha);
y=H;
Y=H;
%%%%%%%%%%%%%%%SECTION 3-PLOTTING THE WALL AND THE FLOOR%%%%%%%%%%%%%%%
A=0;
B=0;
Anew=A+(H+2)/tand(alpha);
Bnew=B+H+2;
plot ( [A Anew] , [B Bnew],'-r','Color', colorstring(1)); hold
on
xlabel('X distance');
ylabel('Y distance');
title('Path of the ball');
A=-15;
B=0;
Anew=0;
Bnew=0;
plot ( [A Anew] , [B Bnew],'-r','Color', colorstring(2)); hold
on
%%%%%%%%%%%%SECTION 4-PLOTTING THE PATH OF THE
BALL%%%%%%%%%%%%%%%%%
while (y>0) %calculate until trajectory goes out of
%bounds
t=t+dt; %incremcwent time
xnew=X-vxo*t; %compute new x-position
ynew=Y+vyo*t-0.5*g*(t^2); %compute new y-position
%to display values of x and y for various time(not required for
the
%solution)
V=fprintf('At time t= %d x= %d y=%d',t,xnew,ynew);
disp(V)
%plot latest segment of trajectory:
plot ( [x xnew] , [y ynew],'-r','Color', colorstring(3)); hold
on
x=xnew;
y=ynew; %update values of x and y
end
legend('wall','floor', 'path of the ball');
hold off
Output graph:
In MATLAB write a program that given the parameters from problem 13.171 (pg 900) that calculates...
this is in reply to the answer I was given for chapter 4
problem 137. Thank you so much for the very complete answer that
you sent down and I just have one remaining question why are they
position vectors inverted. I mean if point P is the origin and then
say you direct that position vector down to see where it touches
the line of force of C then is the position vector inverted as if
it's coming from...