Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
problem 5
  • Loading branch information
nin13001 committed Dec 6, 2017
1 parent a3249ee commit e614f09
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Problem5.m
@@ -0,0 +1,26 @@
set(0, 'defaultAxesFontSize', 16)
set(0,'defaultTextFontSize',14)
set(0,'defaultLineLineWidth',1)
dt=0.1;
x=[0:dt:20]';
y_n=zeros(length(x),4);
y_n(1,:)=[10 0 0 2];
for i=2:length(x)
dy=phugoid_ode(x(i-1),y_n(i-1,:));
y_n(i,:)=y_n(i-1,:)+dt*dy;
end

dt=0.01;
x=[0:dt:20]';
y_n2=zeros(length(x),4);
y_n2(1,:)=[10 0 0 2];
for i=2:length(x)
dy=phugoid_ode(x(i-1),y_n2(i-1,:));
y_n2(i,:)=y_n2(i-1,:)+dt*dy;
end
[t23,y23]=ode23(@(t,y) phugoid_ode(t,y),[0 20],[10 0 0 2]);
d = figure(4);
plot(y_n(:,3),y_n(:,4),y_n2(:,3),y_n2(:,4),y23(:,3),y23(:,4))
legend('Euler .1','Euler .01','ode23','Location','Northeast')
xlabel('Distance')
ylabel('Height')
31 changes: 31 additions & 0 deletions README.md
Expand Up @@ -137,3 +137,34 @@ function x = prob4ptC(prob4_ode, dt, x0,tlimits)
end
```
![](assets/README-ac6c7a25.png)

# Problem 5
```
set(0, 'defaultAxesFontSize', 16)
set(0,'defaultTextFontSize',14)
set(0,'defaultLineLineWidth',1)
dt=0.1;
x=[0:dt:20]';
y_n=zeros(length(x),4);
y_n(1,:)=[10 0 0 2];
for i=2:length(x)
dy=phugoid_ode(x(i-1),y_n(i-1,:));
y_n(i,:)=y_n(i-1,:)+dt*dy;
end
dt=0.01;
x=[0:dt:20]';
y_n2=zeros(length(x),4);
y_n2(1,:)=[10 0 0 2];
for i=2:length(x)
dy=phugoid_ode(x(i-1),y_n2(i-1,:));
y_n2(i,:)=y_n2(i-1,:)+dt*dy;
end
[t23,y23]=ode23(@(t,y) phugoid_ode(t,y),[0 20],[10 0 0 2]);
d = figure(4);
plot(y_n(:,3),y_n(:,4),y_n2(:,3),y_n2(:,4),y23(:,3),y23(:,4))
legend('Euler .1','Euler .01','ode23','Location','Northeast')
xlabel('Distance')
ylabel('Height')
```
![](assets/README-f6577255.png)
Binary file added assets/README-f6577255.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure_04.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions phugoid_ode.m
@@ -0,0 +1,11 @@
function dy=phugoid_ode(t,y)
g=9.81;
vt=5.5;
cl=5.2;
cd=1;
dy=zeros(size(y));
dy(1)=-g*sin(y(2))-cd/cl*g/vt^2*y(1)^2;
dy(2)=-g/y(1)*cos(y(2))+g/vt^2*y(1);
dy(3)=y(1)*cos(y(2));
dy(4)=y(1)*sin(y(2));
end

0 comments on commit e614f09

Please sign in to comment.