ASE 167M - Matlab ODE

# ASE 167M - Matlab ODE - h = Z(end, 2); if(h < -htol) dt...

This preview shows page 1. Sign up to view the full content.

clear all close all clc c global g W Sw CDstar CLstar g CD0 = 0.02; K = 0.07; h0 = 10000; g = 32.2; t0 = 0; W = 11000; CLstar = sqrt(CD0 / K); CDstar = 2 * CD0; Sw = 232; [temp, press, dens, sos] = atmos62(h0); V0 = sqrt(2 * W / (dens * Sw * CLstar)); gamma0 = -1 * CDstar / CLstar; x0 = 0; z0 = [x0; h0; V0; gamma0]; h = h0; t = t0; i = 0; dt = 2; htol = 1e-4; options = odeset('AbsTol', 1e-9, 'RelTol', 1e-9); o while(abs(h) > htol) [T, Z] = ode45('gf_derivs', [t t + dt], z0, options);
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: h = Z(end, 2); if(h < -htol) dt = 0.5 * dt; if (dt < 1e-9) break end elseif(h > htol) z0(:) = Z(end, :); %change maybe t = t + dt; i = i + 1; time(i) = t; x(i) = Z(end, 1); H(i) = Z(end, 2); V(i) = Z(end3); gamma(i) = Z(4); end end e figure(1) plot(time, x) figure(2) plot(time, H) figure(3) plot(time, V) figure(4) plot(time, gamma)...
View Full Document

## This note was uploaded on 09/18/2011 for the course ASE 167M taught by Professor Staff during the Spring '10 term at University of Texas at Austin.

Ask a homework question - tutors are online