problem1_8 - %function of time....

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

View Full Document Right Arrow Icon
function problem1_8 %problem 1.8 %finding depth using Euler's method dt=.5; %step size t=[0:.5:10]'; %time array y=zeros(20,1); y(1)=0; %initial depth disp('t y dydt'); for i=1:202 y(i+1)=y(i)+dt*((1500/1200)*sin(t(i))^2-(500/1200)); %I used a for loop to compute Eulers eqation, and each value %is then stored in the y array so that it can be plotted as a
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %function of time. dydt=(1500/1200)*sin(t(i))^2-(500/1200); fprintf('%2.1f %5.4f %5.4f\n', t(i),y(i+1),dydt); %can't get the last iteration to be displayed end plot(t,y,'r'); xlabel('time'); ylabel('depth'); title('problem 1.8'); end...
View Full Document

This note was uploaded on 09/27/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Ask a homework question - tutors are online