Wind Projectile Motion-Help
1 view (last 30 days)
Show older comments
Hello. Basically I have to write a function to model the motion of a projectile affected by wind in the horizontal direction. This is the code for my function:
function [s]=cannonballWind(u,ang,D,Cdrag,densidad1,densidad2,Ws,dt,g,fig)
%densidad1=projectile density
%densidad2=density of the medium (air) Ws=wind speed
%Cdrag-Drag coeficient for a particular shape
X=[0,0];
a=[0,-g];
s=X(1);
t=0;
ws=[Ws,0];
u1=u*cos(ang);
u2=u*sin(ang);
U=[u1,u2];
volume=(pi*D^3)/6;
m=volume*densidad1;
Ap=(pi*(D^2))/4;%Ap-Proyected Surface
F=[0,-g*m];
Fdrag=[0,0];
while X(2)>=0
Ur=U-ws;
Fdrag=[(-1/2)*Cdrag*densidad2*Ap*abs((Ur(1))*abs(Ur(1))),0];
SF=F+Fdrag;
a=SF./m;
t=t+dt;
U=U+a*dt;
X=X+U*dt;
s=X(1);
end
I feel it makes perfect sense, but it obviously does not, since when I made a trial using the following:
for i=-10:0.5:10
[s]=cannonballWind(10,pi/2,1,0.2,7874,1,i,0.01,9.8,0)
plot (i,s)
hold on
end
It makes a plot that does not make sense. A parabola with negative concavity and vertex in (0,0). It should be a Sigmoid function centered in (0,0)
Thank you for your time
0 Comments
Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!