I\'m trying to plot the trajectory of a missile in matlab I have this code so fa
ID: 1843938 • Letter: I
Question
I'm trying to plot the trajectory of a missile in matlab I have this code so far. From what i know my equations are all correct for FlightTime,MaxRange, and Max Height but how do i plot trajectory? I tried plotting Height vs Flight Time and that does not seem to work.
Velocity = input('What is the Velocity of the missile? ')
LaunchAngle = input('What is the angle the missile was launched at? ')
Gravity = 9.81
FlightTime = 2*Velocity*sind(LaunchAngle)/Gravity
MaxRange = Velocity*cosd(LaunchAngle)*FlightTime
MaxHeight = MaxRange*tand(LaunchAngle)/4
Explanation / Answer
Hi..
You can plot trajectory using Plot function.
The formulae which you have mentioned will calculate for only one data point but in order to plot a trajectory you need to know the range and height of the missile at each time step starting from t=0; Anyways, with maximum height and maximum range also you can plot the trajectory with the below code. Since we have 3 data points the trajectory in not accurate. In order to get the proper curve you need to get atleast 20 data points (height,range) at different time steps.
Velocity= input('What is the Velocity of the missile? ');
LaunchAngle = input('What is the angle the missile was launched at? ');
Gravity = 9.81;
FlightTime= 2*Velocity*sind(LaunchAngle)/Gravity;
MaxRange = Velocity*cosd(LaunchAngle)*FlightTime;
MaxHeight = MaxRange*tand(LaunchAngle)/4;
x= [0,MaxRange/2,MaxRange];
y=[0,MaxHeight,0];
plot(x,y);
Hope its clear.