From ef191eafee3e21de84dcb59948bdc4ca07474416 Mon Sep 17 00:00:00 2001 From: sak13022 Date: Tue, 5 Dec 2017 20:37:20 -0500 Subject: [PATCH] plane --- EC_Plane.m | 23 +++++++++++++++++++++++ EC_Plane_optimum.m | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 EC_Plane.m create mode 100644 EC_Plane_optimum.m diff --git a/EC_Plane.m b/EC_Plane.m new file mode 100644 index 0000000..ce884cd --- /dev/null +++ b/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)') \ No newline at end of file diff --git a/EC_Plane_optimum.m b/EC_Plane_optimum.m new file mode 100644 index 0000000..18ea6a4 --- /dev/null +++ b/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); \ No newline at end of file