Add a replacement for strjoin (missing in MATLAB < R2013a)

As a consequence, revert commits 2e1f189724 and
5d05adeab6.
time-shift
Sébastien Villemot 2019-05-20 12:45:54 +02:00
parent 0461fda782
commit c8e8f04a56
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
5 changed files with 73 additions and 8 deletions

View File

@ -173,6 +173,12 @@ Copyright: 1993-1996 Kurt Hornik
2016 Dynare Team
License: GPL-3+
Files: matlab/missing/strjoin/strjoin.m
Copyright: 2013-2019 Ben Abbott
2007 Muthiah Annamalai
2019 Dynare Team
License: GPL-3+
Files: matlab/missing/corrcoef/corrcoef.m matlab/missing/corrcoef/sumskipnan.m
matlab/missing/corrcoef/flag_implicit_skip_nan.m matlab/missing/corrcoef/tcdf.m
Copyright: 2000-2005,2008,2009,2011 by Alois Schloegl <alois.schloegl@gmail.com>

View File

@ -201,8 +201,7 @@ for jide = 1:4
for j = transpose(ide.problpars{jset}(jrow,:))
probparamset_nbr = probparamset_nbr + 1;
%pno = 100*length(find(ide.ind0(:,j)==0))/SampleSize;
problparnamestring = sprintf('%s,', name{j});
problparnamestring = problparnamestring(1:end-1);
problparnamestring = strjoin(eval(['[', sprintf('name(%d), ', j), ']']),',');
if SampleSize > 1
if length(j) == 1
disp([' ',problparnamestring,' is not identified for ',num2str(pno),'% of MC runs!' ])

View File

@ -122,9 +122,10 @@ if (isoctave && octave_ver_less_than('5')) || (~isoctave && matlab_ver_less_than
p{end+1} = '/missing/isfile';
end
% strsplit is missing in Matlab<R2013a
% strsplit and strjoin are missing in MATLAB < R2013a
if ~isoctave && matlab_ver_less_than('8.1')
p{end+1} = '/missing/strsplit';
p{end+1} = '/missing/strjoin';
end
% isrow, iscolumn and ismatrix are missing in Matlab<R2010b

View File

@ -0,0 +1,63 @@
function rval = strjoin (cstr, delimiter)
% Adapted from Octave's implementation of strjoin
%
% Limitation: escaped characters (e.g. '\n') in delimiters will not be
% interpreted as the characters they represent.
% Copyright (C) 2013-2019 Ben Abbott
% Copyright (C) 2007 Muthiah Annamalai
% Copyright (C) 2019 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if nargin == 1
delimiter = ' ';
elseif nargin < 1 || nargin > 2
error('strjoin: must have either one or two arguments')
end
if ~(iscellstr(cstr) && (ischar(delimiter) || iscellstr(delimiter)))
error('strjoin: first argument must be a cell array, second array either a char array or a cell array')
end
if numel(cstr) == 1
rval = cstr{1};
return;
end
if ischar(delimiter)
% There is no equivalent to do_string_escapes in MATLAB
%delimiter = do_string_escapes(delimiter);
delimiter = {delimiter};
end
num = numel(cstr);
if numel(delimiter) == 1 && num > 1
delimiter = repmat(delimiter, 1, num);
delimiter(end) = {''};
elseif num > 0 && numel(delimiter) ~= num - 1
error('strjoin: the number of delimiters does not match the number of strings');
else
delimiter(end+1) = {''};
end
if num == 0
rval = '';
else
tmp = [cstr(:).'; delimiter(:).'];
rval = [tmp{:}];
end

View File

@ -72,14 +72,10 @@ if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
end
t = ['Plot of '] ;
if options_.rplottype == 0
for j = 1:size(y,1)
t = [t s1{j} ' '] ;
end
hh=dyn_figure(options_.nodisplay,'Name', 'Simulated Trajectory');
plot(ix(i),y(:,i)) ;
title (t,'Interpreter','none') ;
title (['Plot of ' strjoin(s1, ' ')],'Interpreter','none') ;
xlabel('Periods') ;
xlim([min(ix(i)) max(ix(i))])
if length(s1) > 1