source: an2_cellwrite.m @ 15

Last change on this file since 15 was 15, checked in by tjniskan, 12 years ago
  • Almost all of the functions used by Analyze2 start now with a prefix

"an2_".

  • Deleted some depricated functions.

M analyze2.m
D cellsprintf.m
M spectrsum.m
A an2_cellsprintf.m
D calc_wait.m
A an2_calc_wait.m
D getnicedialoglocation.m
A an2_getnicedialoglocation.m
A an2_iseven.m
D iseven.m
M an2_revision.m
D checkcthdr.m
A an2_checkcthdr.m
D fitmaps.m
A an2_fitmaps.m
A an2_read_nifti.m
D read_nifti.m
D mrdread.m
A an2_mrdread.m
D res2table.m
A an2_copy_roi.m
D copy_roi.m
D helpabout.m
A an2_helpabout.m
A an2_res2table.m
D readfid.m
A an2_readfid.m
D readtab.m
A an2_readtab.m
A an2_killfigs.m
D killfigs.m
D roi_stats.m
A an2_roi_stats.m
A an2_juigetfiles.m
D juigetfiles.m
A an2_gui_defaults.m
D gui_defaults.m
D errordump.m
A an2_errordump.m
D export_gui.m
A an2_export_gui.m
D check_file_exist.m
A an2_check_file_exist.m
A an2_cellwrite.m
D cellwrite.m
A an2_rot3d.m
A an2_wbar.m
D wbar.m
D readfdf.m
D rot3d.m
A an2_readfdf.m
M b1_map.m
D uigetfiles.m
D viewprocpar.m
D cdata.mat
A an2_viewprocpar.m
A an2_cdata.mat
A an2_readprocpar.m
D readprocpar.m
A an2_data_read.m
D data_read.m
D surread.m
D deblanke.m
A an2_surread.m
D maptool.m
D resviewer.m
A an2_resviewer.m
A an2_maptool.m
D mriread.m
A an2_mriread.m
A an2_inputdlg.m
D roi_copy_gui.m
A an2_roi_copy_gui.m
D setdefaultbutton.m
D readctdata.m
A an2_readctdata.m
D readfidprefs.m
A an2_readfidprefs.m
D roi_inputdlg.m
M addicon.m
D imaread.m
A an2_imaread.m
D saveres.m
A an2_saveres.m
D rotateflip.m
A an2_rotateflip.m
D editstack.m
A an2_editstack.m
D plugins.m
A an2_plugins.m
M makelcmraw.m
D write_nifti.m
A an2_write_nifti.m

File size: 1.3 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%
7% Description:
8%
9% Examples:
10%
11% See also:
12%
13
14% Juha-Pekka Niskanen - <Juha-Pekka.Niskanen@uku.fi>  -  23.05.2006
15% Department of Biomedical NMR, University of Kuopio
16%
17% Last modified - 27.06.2007 - (J-P N)
18
19% Defaults
20done = false;
21delim = ';';
22
23% Check input arguments
24if nargin<2
25  error('Too few input arguments')
26elseif ~iscell(incell)
27  error('First input argument must be a cell array')
28elseif ~ischar(filename)
29  error('Filename must be of class char')
30end
31
32% Parse Input arguments
33for ii=1:2:length(varargin)
34  switch varargin{ii}
35   case 'delimitter'
36    if strcmpi(varargin{ii+1},'tab')
37      delim = '\t';
38    elseif strcmpi(varargin{ii+1},'space')
39      delim = ' ';
40    else
41      delim=varargin{ii+1};
42    end
43   otherwise
44    msg = sprintf('Unknown parameter "%s"!',varargin{ii});
45    return
46  end
47end
48
49% Open file for writing
50fid = fopen(filename,'w');
51if fid<0
52  msg = sprintf('Could not open file "%s" for writing',filename);
53  return
54end
55
56nRows = size(incell,1);
57nCols = size(incell,2);
58
59% Write cell to file
60for ii=1:nRows
61  for kk=1:nCols
62    fprintf(fid,['%s',delim],incell{ii,kk});
63  end
64  fprintf(fid,'\r\n');
65end
66
67% Close file
68fclose(fid);
69
70% All went well...
71done=true;
72msg='';
73
74% - EOF -
Note: See TracBrowser for help on using the repository browser.

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