problem in plotting in a nested while loop in a for loop
Afficher commentaires plus anciens
i want to plot for different values of Vx. but it is only plotting for one value. please guide
clc
clear all
Vx = [0.7383
1.3266
1.5226
1.6058
1.6388
1.6482
1.6486
1.6494
1.6552
1.6663
1.6787
1.6847
1.6727
1.6240
1.5007
1.1878]*1000;
m=.001;
A=pi*(.007)^2;
C=.9;
rho= 1.2 ;
D=rho*C*A/2;
g=9.81;
%Initial Conditions
delta_t= .001; %s
theta=10; %deg
count=1;
for aa=1:16
nn=1;
x(1)=0;
y(1)=0;
t(1)=0 ;
vin=Vx(aa);
vx=vin*cosd(theta);
vy=vin*sind(theta);
while min(y)> -.001
v = sqrt(vx^2 + vy^2);
ax=-(D/m)*vx^2;
ay=-g-(D/m)*vy^2;
vx=vx+ax*delta_t;
vy=vy+ay*delta_t;
x(nn+1)=x(nn)+vx*delta_t+.5*ax*delta_t^2;
y(nn+1)=y(nn)+vy*delta_t+.5*ay*delta_t^2;
t(nn+1)=t(nn)+delta_t;
nn=nn+1;
end
count=count+1;
plot(x,y)
xlabel('x distance (m)')
ylabel('y distance (m)')
title('Projectile Path')
hold on
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
