1function str = writecellofchar(c)
2
3% Writes a two dimensional cell of char in a string.
4%
5% INPUTS
6% - c   [cell] cell of char.
7%
8% OUTPUTS
9% - str [char]
10%
11% EXAMPLES
12% >> writecellofchar({'a', {'b'; 'c'}})
13%
14% ans =
15%
16% {'a', {'b'; 'c'}}
17%
18% >> writecellofchar({'a', ['b'; 'c'], 'd'})
19%
20% ans =
21%
22%{'a', '['b'; 'c']', 'd'}
23
24% Copyright (C) 2015-2017 Dynare Team
25%
26% This file is part of Dynare.
27%
28% Dynare is free software: you can redistribute it and/or modify
29% it under the terms of the GNU General Public License as published by
30% the Free Software Foundation, either version 3 of the License, or
31% (at your option) any later version.
32%
33% Dynare is distributed in the hope that it will be useful,
34% but WITHOUT ANY WARRANTY; without even the implied warranty of
35% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36% GNU General Public License for more details.
37%
38% You should have received a copy of the GNU General Public License
39% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
40
41str = '{';
42for i=1:size(c, 1)
43for j=1:size(c, 2)
44if iscell(c{i,j})
45str = sprintf('%s%s', str, writecellofchar(c{i, j}));
46elseif ischar(c{i, j})
47if size(c{i, j}, 1)>1
48str = sprintf('%s''%s''', str, writematrixofchar(c{i, j}));
49else
50str = sprintf('%s''%s''', str, c{i, j});
51end
52else
53error('Type not implemenented!')
54end
55if j<size(c, 2)
56str = sprintf('%s, ', str);
57end
58end
59if i<size(c, 1)
60str = sprintf('%s; ', str);
61end
62end
63str = sprintf('%s}', str);