Name

IO_ENTETE — Function to generate a header when printing a matrix with fprintfMat

Calling Sequence

[TITLE,[FORMAT]] = IO_ENTETE(TITLECOL,NBCAR,[NBDEC,NBSTR,HEADCARAC])

Parameters

TITLECOL

Title of each individual column (matrix of string [1xN] where N is the number of columns)

NBCAR

Number of caracters allowed for each column

NBDEC

Number of decimal for the number format (default=3)

NBSTR

Number of string variables (format = %s)

HEADCARAC

Header caracter to be added at the beginning of TITLE(default = #)

TITLE
Data header
FORMAT
Printing format (C language specifications)

Description

  • This function is designed to be used with IO_PRDATA when printing a matrix of data in a text file.

Examples

    // 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;'']);

  

See Also

IO_PRDATA , IO_READDATA , fprintfMat

Authors

Julien Lerat

CEMAGREF Antony, HBAN Unit, julien.lerat@cemagref.fr