% This is an example of a simple program, which % creates a table of y = 2 x2 +3.2 x - 5.6 versus x % as x varies between -2 and +2. % The table is written to file polyreport.txt % % open a stream for the file table = fopen ('polyreport.txt', 'wt'); % calculate arrays x = -2: 0.5 : +2; y = 2 * x .^ 2 + 3.2 * x - 5.6; % print to the screen fprintf( '\n\n Our results \n x y \n'); fprintf( '\n %5.2f %5.2f ', [x ; y ]); % print to the file too fprintf( table ,'\n\n Our results \n x y \n'); fprintf( table , '\n %5.2f %5.2f ', [x ; y] ); fclose( table ); fprintf('\n\n See also file polyreport.txt \n');