Submit individually but work in groups. All your group members can have the same code. New for Milestone 3 1. Upload you
Posted: Tue Jul 12, 2022 8:48 am
clear clc close all % Plotting the target on the interface startmessage = msgbox ('Generate Random Target'); uiwait (startmessage); x3 randi ([10 601,1,1); y3 = randi ([10 30], 1, 1); centers [x3 y3]; radius = 2.5; figure (1) viscircles (centers, radius, 'color', 'r'); xlim ( [0 75]); ylim ( [0 75]); hold on I imread ('angrybirdsbgflip.png'); h image (xlim, ylim, I); uistack (h, 'bottom'); ---User input prompts--- message = msgbox ('Press Ok to Start'); uiwait (message); %--- % Speed Input prompt1= ['Inital Velocity']; dlgtitle1= 'Input Velocity'; dims1 = [1]; speedinput = inputdlg (prompt1); z3 cell2mat (speedinput); ve str2num (z3); % Angle Input
CAN- speedinput = inputdlg (prompt1); z3 = cell2mat (speedinput); v0 = str2num (z3); % Angle Input prompt2 = ['Inital Angle']; dlgtitle2= 'Input Angle'; dims2 = [1]; angleinput z4 = cell2mat tha str2num (z4); x0 = 0; y0 = 0; inputdlg (prompt2); (angleinput); projectile-- % Initial conditions g = 9.81; Cd = 0.3; Launching the m = 5; r = .5; A = pi*r^2; rho 1.225; Fd= .5*rho*Cd*A; score1 = 0; dt = 0.02; tfin = 10; t = 0:dt:tfin; x1 (1) = 0; x2 (1)=v0*cosd (tha) ; y1 (1) = 0; y2 (1) = v0*sind (tha); x1 = zeros (1, 1000); % preallocating for memory y1 = zeros (1, 1000); % preallocating for
x2 (1) y1 (1) = 0; y2 (1) v0*sind (tha) ; x1 = zeros (1, 1000); % preallocating for memory y1 = zeros (1, 1000); % preallocating for memory v0*cosd (tha) ; for n = 1:length(t) x1(n+1) = x1(n) + dt*x2 (n); x2 (n+1) = x2(n) + dt*(- Fd*x2 (n)^2*cosd (tha) /m); y1(n+1)= y1(n) + dt*y2(n); y2 (n+1) = y2(n) + dt*(-g- Fd*y2 (n)^2*sind (tha) /m); centers = [x1(n), y1(n)]; hold on viscircles (centers, r, 'color', 'b'); pause (0.007); viscircles (centers, r, 'color', 'w'); end %--- k = ((x1(n)-x3).^2)+((y1(n)-y3).^2); if y1(n)<-.01 break end if k<10 end Score---- score1 = 1; if score1 == 1 end else msgbox ('You Scored 1 Point!'); msgbox ('Try Again');