OptFEM2DP1 Toolbox  V1.2
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
common/PrintDataInLatexTabular.m
Go to the documentation of this file.
00001 function PrintDataInLatexTabular(Data,Header,DataFormat,ColumnFormat,RowFormat,RowHeaderFormat,LaTeXFilename)
00002 % function PrintDataInLatexTabular(Data,Header,DataFormat,ColumnFormat,RowFormat,RowHeaderFormat,LaTeXFilename)
00003 %   To manage the printing of tabulars in Latex files
00004 %   
00005 % Copyright:
00006 %   See \ref license
00007 
00008   [nR,nCG]=size(Data);
00009   nC=length(Header);
00010   if isempty(LaTeXFilename)
00011     fid=1;
00012   else
00013   fid=fopen(LaTeXFilename,'w');
00014    if (fid == -1)
00015     error(['Cannot open file ',LaTeXFilename]);
00016    end
00017   end
00018 
00019   fprintf(fid,'\\begin{tabular}{%s}\n',ColumnFormat);
00020   fprintf(fid,'  %s \n',RowFormat);
00021   
00022   % Header
00023   FFormat=DataFormat{1};
00024   for i=1:nC-1
00025     fprintf(fid,'  %s &',Header{i});
00026     FFormat=sprintf('%s & %s',FFormat,DataFormat{i+1});
00027   end
00028   fprintf(fid,'  %s ',Header{nC});
00029   fprintf(fid,' \\\\ %s\n',RowHeaderFormat);
00030   
00031   for i=1:nR
00032     fprintf(fid,FFormat,Data(i,:));
00033     fprintf(fid,'\\\\ %s\n',RowFormat);
00034   end
00035   
00036   fprintf(fid,'\\end{tabular}\n');
00037   if (fid ~=1)
00038     fclose(fid);
00039     fprintf(' -> %s\n',LaTeXFilename);
00040   end
00041 end
 All Files Functions