source: an2_cellwrite.m @ 36

Last change on this file since 36 was 36, checked in by tjniskan, 11 years ago
  • Added option to an2_readfid, an2_data_read and an2_readfidprefs

which allows controlling the output precision. Default is 'double'
(which is more precise), but if you have a very long data changing
this to 'single' will half the memory requirements.

  • Rewrote an2_inputdlg so that it does not depend on Matlab license.
  • Deleted many depricated files.
  • Moved addicon.m under misclib.
  • Added Analyze2 under GNU General Public License (version 2).
  • Added GPL license in license.txt file and added license

notifications in m-files.

M an2_export_gui.m
M analyze2.m
M an2_cellsprintf.m
M an2_getfilefilter.m
M an2_calc_wait.m
D an2_getnicedialoglocation.m
D misclib/uiclear.m
M misclib/spectrsum.m
M misclib/shiftind.m
M misclib/dcm_info.m
D misclib/b1_map.m
A misclib/addicon.m
M misclib/makelcmraw.m
M an2_check_file_exist.m
M an2_iseven.m
M an2_cellwrite.m
M an2_wbar.m
M an2_rot3d.m
M an2_readfdf.m
M an2_revision.m
M an2_viewprocpar.m
M an2_checkcthdr.m
D an2_questerrordlg.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
A license.txt
M an2_resviewer.m
M an2_maptool.m
M an2_res2table.m
M an2_helpabout.m
M an2_copy_roi.m
M plugins/save_roi_as_mask.m
M plugins/write_difference_images.m
M plugins/plot_profile.m
M plugins/calculate_t2_map.m
M plugins/calculate_t1r_map.m
M plugins/view_kspace.m
M plugins/copy_data_to_workspace.m
M plugins/take_snapshot.m
M an2_inputdlg.m
M an2_roi_copy_gui.m
M an2_readctdata.m
D an2_setdefaultbutton.m
M an2_readfid.m
M an2_readfidprefs.m
D addicon.m
M an2_readtab.m
D an2_imaread.m
M an2_check_updates.m
M an2_killfigs.m
M an2_roi_stats.m
M an2_saveres.m
M an2_rotateflip.m
M an2_juigetfiles.m
M an2_gui_defaults.m
M an2_editstack.m
M an2_errordump.m
M an2_update.m
M an2_write_nifti.m

File size: 1.9 KB
Line 
1function [done,msg] = an2_cellwrite(incell,filename,varargin)
2% AN2_CELLWRITE - Write cell array to a text file
3%   
4%
5% Synopsis:
6%        [done,msg] = an2_cellwrite(incell,filename,varargin)
7%
8% Description:
9%
10% Examples:
11%
12% See also:
13%        ANALYZE2
14
15% This function is a part of Analyze 2.0 - A graphical tool for analyzing
16% medical images
17%
18% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
19%
20% Department of Physics, (or Department of Neurobiology)
21% University of Kuopio,
22% P.O. Box 1627,
23% FIN-70211, Kuopio
24% FINLAND
25%
26% This program may be used under the terms of the GNU General Public
27% License version 2.0 as published by the Free Software Foundation
28% and appearing in the file LICENSE.TXT included in the packaging of
29% this program.
30%
31% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
32% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
33
34
35
36% Defaults
37done = false;
38delim = ';';
39
40% Check input arguments
41if nargin<2
42  error('Too few input arguments')
43elseif ~iscell(incell)
44  error('First input argument must be a cell array')
45elseif ~ischar(filename)
46  error('Filename must be of class char')
47end
48
49% Parse Input arguments
50for ii=1:2:length(varargin)
51  switch varargin{ii}
52   case 'delimitter'
53    if strcmpi(varargin{ii+1},'tab')
54      delim = '\t';
55    elseif strcmpi(varargin{ii+1},'space')
56      delim = ' ';
57    else
58      delim=varargin{ii+1};
59    end
60   otherwise
61    msg = sprintf('Unknown parameter "%s"!',varargin{ii});
62    return
63  end
64end
65
66% Open file for writing
67fid = fopen(filename,'w');
68if fid<0
69  msg = sprintf('Could not open file "%s" for writing',filename);
70  return
71end
72
73nRows = size(incell,1);
74nCols = size(incell,2);
75
76% Write cell to file
77for ii=1:nRows
78  for kk=1:nCols
79    fprintf(fid,['%s',delim],incell{ii,kk});
80  end
81  fprintf(fid,'\r\n');
82end
83
84% Close file
85fclose(fid);
86
87% All went well...
88done=true;
89msg='';
90
91% - EOF -
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008