Sunday, October 26, 2014

Writing text output of a table

    % open file, write out header
    % write out transpose of table4, with six total places per column, two decimal places (or none for npts)

    fileID = fopen('table4.txt','w');
    fprintf(fileID,'%6s %6s %6s %6s %6s %6s \n',
            'a', 'b1', 'b2', 'R^2', 
            'rmse', 'npts');
    fprintf(fileID,'%6.2f %6.2f %6.2f %6.2f 
            %6.2f %6.0f \n',table4');
    fclose(fileID);