Home > cellorganizer > utilities > print2file.m

print2file

PURPOSE ^

PRINT2FILE Helper function that prints the contents of an array on a

SYNOPSIS ^

function print2file( array, tabs, fileID )

DESCRIPTION ^

PRINT2FILE Helper function that prints the contents of an array on a
file using MathML presentation format.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function print2file( array, tabs, fileID )
0002 %PRINT2FILE Helper function that prints the contents of an array on a
0003 %file using MathML presentation format.
0004 
0005 % Author: Ivan E. Cao-Berg (icaoberg@cmu.edu)
0006 % Created: May 8, 2007
0007 % Last Update: March 19, 2008
0008 %
0009 % Copyright (C) 2008 Center for Bioimage Informatics/Murphy Lab
0010 % Carnegie Mellon University
0011 %
0012 % This program is free software; you can redistribute it and/or modify
0013 % it under the terms of the GNU General Public License as published
0014 % by the Free Software Foundation; either version 2 of the License,
0015 % or (at your option) any later version.
0016 %
0017 % This program is distributed in the hope that it will be useful, but
0018 % WITHOUT ANY WARRANTY; without even the implied warranty of
0019 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0020 % General Public License for more details.
0021 %
0022 % You should have received a copy of the GNU General Public License
0023 % along with this program; if not, write to the Free Software
0024 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0025 % 02110-1301, USA.
0026 %
0027 % For additional information visit http://murphylab.web.cmu.edu or
0028 % send email to murphy@cmu.edu
0029 
0030 %to avoid truncation
0031 format long
0032 
0033 % print an array
0034 fprintf( fileID, [tabs '%s\n'], ['<array dimensions="(' num2str(size(array,1)) ',' num2str(size(array,2)) ')">'] );
0035 for i=1:1:size(array,1)
0036     for j=1:1:size(array,2)
0037         if array(i,j) ~= 0
0038             fprintf( fileID, [tabs '\t%s\n'], ['<number index="(' num2str(i) ','  num2str(j) ')">' num2str(array(i,j)) '</number>'] );
0039         end
0040     end
0041 end
0042 fprintf( fileID, [tabs '%s\n'], '</array>' );
0043 end%print2file

Generated on Sun 29-Sep-2013 18:44:06 by m2html © 2005