hw07_p05 - end; fprintf(fid4,'\n\nh = %10.5f\n', h);

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

View Full Document Right Arrow Icon
% File: hw07_p05.m % Function file: hw07_p05trap.m % Written by Jason Kenny and modified by Sangheon Lee % clc clear c a = 0.25 Si = 0.8 lambda = 1 sigma = 0.25 mu = 1 m t(1) = 0 R(1) = a h = 1/16 tol = 0.0000001; n = 1; n t(n+1) = t(n) + h; [Rpred(n+1), R(n+1)] = hw07_p05trap(t(n), R(n), h, Si, lambda, sigma, mu); n = n+1; n % open file fid4 = fopen('hw07_p05_answer.txt','wt'); % 'wt' means "write text" if (fid4 < 0) error('could not open file "hw07_p05_answer.txt"');
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end; fprintf(fid4,'\n\nh = %10.5f\n', h); fprintf(fid4,'n\t\t\t\tt\t\t\t\tR(t)\n'); fprintf(fid4,'%10d%15.5f%15.5f\n', n,t(n),R(n)); while ( abs( R(n) - R(n-1) ) > tol ) t(n+1) = t(n) + h; [Rpred(n+1), R(n+1)] = hw07_p05trap(t(n), R(n), h, Si, lambda, sigma, mu); n = n+1; if mod(n,20) == 0 fprintf(fid4,'%10d%15.5f%15.5f\n', n,t(n),R(n)); end end fprintf(fid4,'%10d%15.5f%15.5f\n', n,t(n),R(n)); fclose(fid4);...
View Full Document

This note was uploaded on 02/22/2010 for the course CHE 348 taught by Professor Chelikowsky during the Spring '08 term at University of Texas at Austin.

Ask a homework question - tutors are online