Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
plane
  • Loading branch information
sak13022 committed Dec 6, 2017
1 parent 473a72b commit ef191ea
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
23 changes: 23 additions & 0 deletions EC_Plane.m
@@ -0,0 +1,23 @@
function [distance,z]=EC_plane(theta0,y0,v0)
dt=0.1; %timestep (s)
v(1)=v0; %initial velocity (m/s)
n=1; %counter
theta(1)=theta0; %initial angle (rad)
x(1)=0; %initial x location (m)
y(1)=y0; %initial y location (m)
g = 9.81; % gravity in m s^{-2}
vt = 5.5; % trim velocity in m s^{-1}
LD=5.2;
while y(end)>0
v(n+1)=v(n)+dt*(-g*sind(theta(n))-(1/LD)*(g)*((v(n))^2)/(5.5^2));
theta(n+1)=theta(n)+dt*((-g)*cosd(theta(n))/v(n) + g*v(n)/(5.5^2));
x(n+1)=x(n)+dt*v(n)*cosd(theta(n));
y(n+1)=y(n)+dt*v(n)*sind(theta(n));
n = n+1;
end
z = [v',theta',x',y'];
distance=x(end);
plot(x,y);
title('Paper Airplane Flight Path')
xlabel('Distance (x)')
ylabel('Height (x)')
21 changes: 21 additions & 0 deletions EC_Plane_optimum.m
@@ -0,0 +1,21 @@
clear
clc

v0 = 10; %initial velocity (m/s)
y0 = 2; %initial height (m)
deg = linspace(0,90); %0 to 90 degree launch angle
vel = linspace(0,10); %0 to 10 m/s launch velocity
d = zeros(1,100);
for i = 1:length(deg)
theta0 = deg(1); %converts degrees to radians
[d(i),u] = EC_Plane(theta0,y0,v0);
end
[a,b]= max(d);
theta0 = deg(b);
for i = 1:100
v0 = vel(i);
[d(i),u] = EC_Plane(theta0,y0,v0);
end
[c,e] = max(d);
v0 = vel(e);
[x,u] = EC_Plane(theta0,y0,v0);

0 comments on commit ef191ea

Please sign in to comment.