hw06_p05 - % 'wt' means "write...

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

View Full Document Right Arrow Icon
clc clear format long f x0 = input('Initial guess in a row vector form: '); xold = x0; tolerance = input('tolerance:'); t tolerance = 0.0001 n = 1; n [xnew(1), xnew(2)] = hw06_p05_newton( xold(1), xold(2) ); disp(xnew) d while ( abs( xnew(1) - xold(1) ) > tolerance | abs( xnew(2) - xold(2) ) > tolerance ) xold = xnew; [xnew(1), xnew(2)] = hw06_p05_newton( xold(1), xold(2) ); disp(xnew) n = n + 1; end % open file fid4 = fopen('hw06_p05_answer.txt','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: % 'wt' means "write text" if (fid4 < 0) error('could not open file "hw06_p04_answer.txt"'); end; fprintf(fid4,'\n\nInitial guesses are \n'); for i = 1:length(x0) fprintf(fid4,'%15.5f\n',x0(i)); end fprintf(fid4,'Tolerance = %10.3e\n',tolerance); fprintf(fid4,'Number of iteration = %10d\n',n); fprintf(fid4,'Solutions are \n'); for i = 1:length(xnew) fprintf(fid4,'%15.5f\n',xnew(i)); end fclose(fid4); disp(n)...
View Full Document

Ask a homework question - tutors are online