{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw06_p03b - if(fid4< 0 error'could not open...

Info icon This 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:'); n = 1; n [xnew(1), xnew(2)] = hw06_p03b_newton( xold(1), xold(2) ); [ while ( abs( xnew(1) - xold(1) ) > tolerance | abs( xnew(2) - xold(2) ) > tolerance ) xold = xnew; [xnew(1), xnew(2)] = hw06_p03b_newton( xold(1), xold(2) ); n = n + 1; end % open file fid4 = fopen('hw06_p03b_answer.txt','a'); % 'wt' means "write text"
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (fid4 < 0) error('could not open file "hw06_p03b_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) d...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern