Home > atmlab > files > strs2file.m

strs2file

PURPOSE ^

STRS2FILE Prints a string array to a file.

SYNOPSIS ^

function strs2file( filename, S )

DESCRIPTION ^

 STRS2FILE   Prints a string array to a file.

    The function creates an ASCII file and puts each item of *S* as
    row into the file. That is, S{3} becomes row 3 of the file.

 FORMAT   strs2file( filename, S )
        
 IN    filename   Name of file to create.
       S          Cell array of strings.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

strs2file.m

SOURCE CODE ^

0001 % STRS2FILE   Prints a string array to a file.
0002 %
0003 %    The function creates an ASCII file and puts each item of *S* as
0004 %    row into the file. That is, S{3} becomes row 3 of the file.
0005 %
0006 % FORMAT   strs2file( filename, S )
0007 %
0008 % IN    filename   Name of file to create.
0009 %       S          Cell array of strings.
0010 
0011 % 2010-01-12   Created by Patrick Eriksson.
0012 
0013 
0014 function strs2file( filename, S )
0015                                                                            %&%
0016 %= Check input                                                             %&%
0017 %                                                                          %&%
0018 rqre_nargin( 2, nargin );                                                  %&%
0019 rqre_datatype( S, @iscellstr );                                            %&%
0020 
0021 
0022 %= Open file for writing
0023 %
0024 fid = fileopen( filename, 'w' );
0025 
0026 
0027 %= Loop and write lines
0028 %
0029 for i = 1 : length(S)
0030   fprintf( fid, '%s\n', S{i} );
0031 end
0032 
0033 
0034 %= Close file
0035 %
0036 fid = fileclose( fid );

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005