When trying to plot a graph nothing but the x axis and y axis are displayed in the figure. The code is for drawing the approximate path of a projectile which is experiencing drag.
close all%constants and starting conditions
g =-9.81;A = 0.25 * pi * (0.01512); %with 15.12mm the diameter of the projectile
ro = 1.293; %Binas' air density at 20C at sea level
c = 0.47; %drag coefficient for a sphere
B = 45; %launch angle
Xx = 0;Xy = 1-sin(B)*0.202; %projectile-floor height in meters
Vc = 10.66; %launch speed in meters per second
Vx = sin(B)*Vc; %horizontal speed vector
Vy = cos(B)*Vc; %vertical speed vector
dt = 0.1; %timestep
m = 0.001684;%projectile mass in kilograms
awx(1) = 0;awy(1) = 0;dVy(1) = 0;dVx(1) = 0;dXx(1) = 0;dXy(1) = 0;Fwx(1) = 0;Fwy(1) = 0;t(1) = 0;%model
while Xy >= 0 ax = awx; Vx = Vx+dVx; dVx = ax*dt; Xx = Xx+dXx; dXx = Vx*dt+0.5*ax*(dt)^2; ay = g+awy; Vy = Vy+dVy; dVy = ay*dt; Xy = Xy+dXy; dXy = Vy*dt+0.5*ay*(dt)^2; Vd = sqrt((Vx)^2+(Vy)^2);%sum of both speed vectors in flight
Fw = -0.5*ro*A*c*(Vd)^2; theta = atan((Vx)/(Vy));%angle of Vd in fight
Fwy = cos(theta)*Fw; Fwx = sin(theta)*Fw; awx = (Fwx)/m; awy = (Fwy)/m; t = t+dt;end plot(Xx,Xy) xlabel('x (m)') ylabel('y (m)') title('Projectile Path')
Best Answer