source: aedes_cellwrite.m

Last change on this file was 80, checked in by tjniskan, 9 years ago
  • Changed the historical "an2_" prefix to "aedes_" in all files. NOTE:

Any script or function relying to Aedes functions will be broken
because of this. Just do a search/replace from "an2_" to "aedes_" in
your files and all should be well...

  • Changed the name of an2_readtab.m to a more informative

aedes_readphasetable.m

File size: 1.9 KB
Line 
1function [done,msg] = aedes_cellwrite(incell,filename,varargin)
2% AEDES_CELLWRITE - Write cell array to a text file
3%   
4%
5% Synopsis:
6%        [done,msg] = aedes_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, 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