% Team OD-3 Estabrook Critter Conker Project % Clear memory. clear all; clc; % Get Input Data Velball_Tdistance = inputdlg({'Initial Velocity of Paintball (ft/s)','Distance from Launch Point(ft)'},... 'The Estabrook Critter Conker',[1 60; 1 60],{'35','20'},'on'), Velball = eval(char(Velball_Tdistance(1))); Tdistance = eval(char(Velball_Tdistance(2))); %check distance while Tdistance<20 | Tdistance>30 check_distance=inputdlg('Valid range for target distance is 20ft - 30ft.',... 'Error!',[1 60],{'20'},'on'); Tdistance=eval(char(check_distance)); end %Define Constants and dimensions of target and wall Target_x = Tdistance; Target_y = 0; dwall_x = 10; %distance from origin hwall_y = 4; %wall height G = -32.2; % accel grav x_0 = 0; %Launch pad position y_0 = 0; % " " time = 0.001; % Convert Degrees to Radians d2r = inline('a.*pi./180'); %target hit loop j=1 while j>0 & j <= 90 wall = y_0 + (tan(d2r(j)).*dwall_x) + (.5.*G.*((dwall_x./(Velball.*cos(d2r(j)))).^2)); if wall=hwall_y+.5 h0_1 = y_0 + (tan(d2r(j)).*Target_x) + (.5.*G.*((Target_x./(Velball.*cos(d2r(j)))).^2)); if h0_1>Target_y j=j+.1; elseif h0_1<=Target_y vx_0 = Velball .* cos(d2r(j)); % X-component of ball velocity vy_0 = Velball .* sin(d2r(j)); % Y-component of ball velocity k = 1 x1(k) = x_0; y1(k) = y_0; vx1_(k) = vx_0; vy1_(k) = vy_0; % increment until target is hit while y1(k)>=Target_y vx1_(k+1) = vx1_(k); vy1_(k+1) = vy1_(k) + (G .* time) ; x1(k+1) = x1(k) + ((vx1_(k)).* time); y1(k+1) = y1(k) + (vy1_(k).*time) + (.5.*G.*(time.^2)); k=k+1; end if ceil(x1(k)+.25)90 check_Velball=inputdlg('Please re-enter a higher initial velocity',... 'Error! Velocity too low!',[1 60],{'50'},'on'); Velball=eval(char(check_Velball(1))); j=1; end time_air=Target_x./(Velball.*cos(d2r(j))); end % Activate figure 1 and clear all values figure(1); clf reset; hold on; axis([ -.5 30 -.5 20]); %wall coordinates box_x=[dwall_x dwall_x dwall_x+.3 dwall_x+.3]; box_y=[0 hwall_y hwall_y 0]; plot(x1,y1,'b-', box_x, box_y,'k'); %Annotate Plot title('Estabrook Critter Conker - Team OD-3 - 4/25/03'); xlabel('Horizontal Position - ft'); Ylabel('Vertical Position - ft'); %text(.5,.9.*(h0+tl+3),['Launch height=',num2str(y0,2),'ft']); text(20,18,['Distance = ',num2str(Target_x,2),' ft']); text(20,17,['Angle = ',num2str(j,2),'^o']); text(20,16,['Time in Air = ',num2str(time_air,2),' secs']); %End of Program