Use Matlab to plot the trajectory in 3D of a shell fired wit

Use Matlab to plot the trajectory in 3D of a shell fired with a speed of V0=800m/s at an elevation of 37o from a battleship at latitude 50oS

Solution

%input parameters
v0=input(\'Enter the muzzle velocity (m/s) \');
theta=input(\'Enter the quadrant elevation (degrees) \');
%T0=input(\'Enter the value for the ground temperature in degreees \');
%T0=T0+275.16;

b2bym0=4e-5;
g=9.8;
dt=1e-2;

%define initial conditions
x0=0;
y0=0;
vx0=v0*cosd(theta);
vy0=v0*sind(theta);
fdragx=-b2bym0*v0*vx0;
fdragy=-b2bym0*v0*vy0;

n=1000; %iterations

%Tratio=(T0/300)^(2.5);

%define data array
%t=zeros(1000);

x=zeros(1000); %x-position

y=zeros(1000); %y-position

vx=zeros(1000); %x-velocity

vy=zeros(1000); %y-velocity

for i=1:n

t(i)=i*dt;

vx(i)=vx0+fdragx*dt;
vy(i)=vy0+fdragy*dt;

x(i)=x0+vx(i)*dt;
y(i)=y0+vy(i)*dt;

x0=x(i);
y0=y(i);

vx0=vx(i);
vy0=vy(i);

end
plot(x,y,\'g+\')

Use Matlab to plot the trajectory in 3D of a shell fired with a speed of V0=800m/s at an elevation of 37o from a battleship at latitude 50oSSolution%input param

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site