1function str = writematrixofchar(m) 2 3% Writes a matrix of char in a string. 4% 5% INPUTS 6% - m [char] matrix of char. 7% 8% OUTPUTS 9% - str [char] 10% 11% EXAMPLE 12% >> writematrixofchar(['a'; 'b']) 13% 14% ans = 15% 16% ['a'; 'b'] 17% 18% where the returned argument is a string which can be evaluated or printed. 19 20% Copyright (C) 2015-2017 Dynare Team 21% 22% This file is part of Dynare. 23% 24% Dynare is free software: you can redistribute it and/or modify 25% it under the terms of the GNU General Public License as published by 26% the Free Software Foundation, either version 3 of the License, or 27% (at your option) any later version. 28% 29% Dynare is distributed in the hope that it will be useful, 30% but WITHOUT ANY WARRANTY; without even the implied warranty of 31% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 32% GNU General Public License for more details. 33% 34% You should have received a copy of the GNU General Public License 35% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 36 37if ~(ischar(m) && ismatrix(m)) 38 error('Input has to be a matrix of char!') 39end 40 41str = '['; 42for i=1:size(m, 1) 43 str = sprintf('%s''%s''', str, m(i,:)); 44 if i<size(m, 1) 45 str = sprintf('%s; ', str); 46 end 47end 48str = sprintf('%s]', str);