IO_ENTETE — Function to generate a header when printing a matrix with fprintfMat
[TITLE,[FORMAT]] = IO_ENTETE(TITLECOL,NBCAR,[NBDEC,NBSTR,HEADCARAC])
Title of each individual column (matrix of string [1xN] where N is the number of columns)
Number of caracters allowed for each column
Number of decimal for the number format (default=3)
Number of string variables (format = %s)
Header caracter to be added at the beginning of TITLE(default = #)
This function is designed to be used with IO_PRDATA when printing a matrix of data in a text file.
// Data Matrix DATA=rand(100,3); // Txt Matrix TXT = strsplit(code2str(int(10*rand(100,1))+10),1:99); // Column title TC = ['SomeText' 'col1' 'column2' 'c3']; // Header [T,F] = IO_ENTETE(TC,15,3,1); // Matrix printing fprintfMat (limited format specifications + no text) f=fprintfMat(TMPDIR+'/MyData1.txt',DATA,'%8.2f',T); // Matrix printing with mfprintf (extended format specifications + printing text possible) f=mopen(TMPDIR+'/MyData2.txt','a'); mfprintf(f,'%s\n',T); // Prints header mfprintf(f,F,TXT,DATA); // Prints data mclose(f); // Matrix printing with IO_PRDATA (same as mfprintf but simpler !) IO_PRDATA(TMPDIR+'/MyData3.txt',F,DATA,TXT,['-- This is the header --';'';T;'']);