printMatrix Prints matrix into a file or screen printMatrix(A,format,file) A Matrix format Format string (opt,default '%6.4f\t') file File name (opt) Markus Herrgard
0001 function printMatrix(A,format,file) 0002 %printMatrix Prints matrix into a file or screen 0003 % 0004 % printMatrix(A,format,file) 0005 % 0006 % A Matrix 0007 % format Format string (opt,default '%6.4f\t') 0008 % file File name (opt) 0009 % 0010 % Markus Herrgard 0011 0012 if (nargin < 2) 0013 format = '%6.4f\t'; 0014 end 0015 if (nargin < 3) 0016 fid = 1; 0017 else 0018 fid = fopen(file,'w'); 0019 end 0020 0021 [n,m] = size(A); 0022 0023 for i = 1:n 0024 for j = 1:m 0025 if (~iscell(A)) 0026 fprintf(fid,format,A(i,j)); 0027 else 0028 fprintf(fid,format,A{i,j}); 0029 end 0030 end 0031 fprintf(fid,'\n'); 0032 end