Contents

Aaron Klapheck

% In class
clear, clc, home
fprintf('The date and time: %s \n', datestr(now))
The date and time: 19-Feb-2008 13:55:00 

fprintf to screen

A = [3.34321, 4; 23, 6; 9, 12];

fprintf('\t Matrix A \n')
fprintf('\t ------------ \n')
fprintf('\t %8.4f %8.0f \n', A')

fprintf(' \n \n')

a = 25.345292; b = -3.531;
fprintf('\t a(cm)   \t b(cm) \n')
fprintf('\t -----   \t ----- \n')
fprintf('\t %6.4f   \t %1.5f \n', a,b)
	 Matrix A 
	 ------------ 
	   3.3432        4 
	  23.0000        6 
	   9.0000       12 
 
 
	 a(cm)   	 b(cm) 
	 -----   	 ----- 
	 25.3453   	 -3.53100 

fprintf to file

fprintf('Write to a file called Fprinting \n \n')

% write to the m file named f_printing.

indin = fopen('Fprinting.dat', 'w')

    % Tell user if file was opened sucessfully.
    if indin > 0
        fprintf('File Fprinting opened/created sucessfully \n \n')
    else
        fprintf('Warning! File Fprinting not opened/created \n \n')
    end % if fileID > 0

    a = 25.345292; b = -3.531;
    fprintf(indin, '\t a(cm)   \t b(cm) \n');
    fprintf(indin, '\t -----   \t ----- \n');
    fprintf(indin, '\t %6.4f   \t %1.5f \n', a,b);

cl = fclose(indin);

% stop writing

% Tell user if file was closed sucessfully.

if cl == 0
    fprintf('File Fprinting closed succesfully \n \n')
else
    fprintf('Warning! File Fprinting not closed \n \n')
end % if cl == 0

% Show the data that was writen to f_printing.dat
fprintf('Wrote the folowing to Fprinting.dat: \n')
type('Fprinting.dat')
Write to a file called Fprinting 
 

indin =

     3

File Fprinting opened/created sucessfully 
 
File Fprinting closed succesfully 
 
Wrote the folowing to Fprinting.dat: 

	 a(cm)   	 b(cm) 
	 -----   	 ----- 
	 25.3453   	 -3.53100