source: an2_cellwrite.m @ 44

Last change on this file since 44 was 39, checked in by tjniskan, 11 years ago
  • Added "Recent Files" quick access menu in File-menu
  • Fixed a bug in plugins/copy_data_to_workspace.m that made writing a

new name for a variable difficult

  • Fixed a bug in the file prefix editbox in an2_export_gui.m
  • Changed references to Analyze 2.0 in all license notices to Aedes.

The name change should now be complete...

M an2_export_gui.m
M an2_cellsprintf.m
M an2_calc_wait.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
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
M an2_resviewer.m
M an2_maptool.m
M aedes.m
M an2_res2table.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
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.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_update.m
M an2_write_nifti.m

File size: 1.8 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%        AEDES
14
15% This function is a part of Aedes - 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, FINLAND
22%
23% This program may be used under the terms of the GNU General Public
24% License version 2.0 as published by the Free Software Foundation
25% and appearing in the file LICENSE.TXT included in the packaging of
26% this program.
27%
28% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30
31
32
33% Defaults
34done = false;
35delim = ';';
36
37% Check input arguments
38if nargin<2
39  error('Too few input arguments')
40elseif ~iscell(incell)
41  error('First input argument must be a cell array')
42elseif ~ischar(filename)
43  error('Filename must be of class char')
44end
45
46% Parse Input arguments
47for ii=1:2:length(varargin)
48  switch varargin{ii}
49   case 'delimitter'
50    if strcmpi(varargin{ii+1},'tab')
51      delim = '\t';
52    elseif strcmpi(varargin{ii+1},'space')
53      delim = ' ';
54    else
55      delim=varargin{ii+1};
56    end
57   otherwise
58    msg = sprintf('Unknown parameter "%s"!',varargin{ii});
59    return
60  end
61end
62
63% Open file for writing
64fid = fopen(filename,'w');
65if fid<0
66  msg = sprintf('Could not open file "%s" for writing',filename);
67  return
68end
69
70nRows = size(incell,1);
71nCols = size(incell,2);
72
73% Write cell to file
74for ii=1:nRows
75  for kk=1:nCols
76    fprintf(fid,['%s',delim],incell{ii,kk});
77  end
78  fprintf(fid,'\r\n');
79end
80
81% Close file
82fclose(fid);
83
84% All went well...
85done=true;
86msg='';
87
88% - EOF -
Note: See TracBrowser for help on using the repository browser.

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