Various MATLAB R2014a compatibility fixes
parent
8d4f5fbd9b
commit
e42cf2e5b4
|
@ -98,7 +98,11 @@ if T_max > 0
|
||||||
for i = T_max-1:-1:1
|
for i = T_max-1:-1:1
|
||||||
tmp = 0*binding_indicator;
|
tmp = 0*binding_indicator;
|
||||||
tmp(1:end-i+1,:) = binding_indicator(i:end,:);
|
tmp(1:end-i+1,:) = binding_indicator(i:end,:);
|
||||||
itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:)));
|
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
|
||||||
|
itmp = find(~any(bsxfun(@minus, dictionary.binding_indicator(1:length(tmp)*2,:), tmp(:))));
|
||||||
|
else
|
||||||
|
itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:)));
|
||||||
|
end
|
||||||
if ~isempty(itmp)
|
if ~isempty(itmp)
|
||||||
ireg(i) = itmp;
|
ireg(i) = itmp;
|
||||||
else
|
else
|
||||||
|
@ -166,4 +170,4 @@ for irfpos=2:n_periods+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
zdata = history(:,2:end)';
|
zdata = history(:,2:end)';
|
||||||
|
|
|
@ -89,7 +89,11 @@ if T_max > 0
|
||||||
|
|
||||||
tmp = 0*binding_indicator;
|
tmp = 0*binding_indicator;
|
||||||
tmp(1:end-i+1) = binding_indicator(i:end);
|
tmp(1:end-i+1) = binding_indicator(i:end);
|
||||||
itmp = find(~any(dictionary.binding_indicator-tmp));
|
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
|
||||||
|
itmp = find(~any(bsxfun(@minus, dictionary.binding_indicator, tmp)));
|
||||||
|
else
|
||||||
|
itmp = find(~any(dictionary.binding_indicator-tmp));
|
||||||
|
end
|
||||||
if ~isempty(itmp)
|
if ~isempty(itmp)
|
||||||
ireg(i) = itmp;
|
ireg(i) = itmp;
|
||||||
else
|
else
|
||||||
|
@ -148,4 +152,4 @@ for irfpos=2:n_periods+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
zdata = history(:,2:end)';
|
zdata = history(:,2:end)';
|
||||||
|
|
|
@ -74,9 +74,17 @@ end
|
||||||
|
|
||||||
% add back steady state
|
% add back steady state
|
||||||
if ~options_.occbin.simul.piecewise_only
|
if ~options_.occbin.simul.piecewise_only
|
||||||
out.linear = out.linear + out.ys';
|
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
|
||||||
|
out.linear = bsxfun(@plus, out.linear, out.ys');
|
||||||
|
else
|
||||||
|
out.linear = out.linear + out.ys';
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
|
||||||
|
out.piecewise = bsxfun(@plus, out.piecewise, out.ys');
|
||||||
|
else
|
||||||
|
out.piecewise = out.piecewise + out.ys';
|
||||||
end
|
end
|
||||||
out.piecewise = out.piecewise+ out.ys';
|
|
||||||
out.exo_pos = options_.occbin.simul.exo_pos;
|
out.exo_pos = options_.occbin.simul.exo_pos;
|
||||||
|
|
||||||
oo_.occbin=out;
|
oo_.occbin=out;
|
||||||
|
|
|
@ -51,14 +51,18 @@ else
|
||||||
xlsmat{tp,5}=int2str(regime_history(tp).regimestart2);
|
xlsmat{tp,5}=int2str(regime_history(tp).regimestart2);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
filename=[OutputDirectoryName filesep xls_filename '.xls'];
|
if ~ispc && ~isoctave && matlab_ver_less_than('9.0')
|
||||||
if matlab_ver_less_than('9.3')
|
% On GNU/Linux and macOS, with MATLAB < R2016a, “writeable” can’t write Excel files
|
||||||
if exist(filename,'file')
|
warning('This version of MATLAB is too old and cannot create Excel files. The Occbin regimes will rather be written to a CSV file')
|
||||||
delete(filename)
|
filename=[OutputDirectoryName filesep xls_filename '.csv'];
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if isfile(filename)
|
filename=[OutputDirectoryName filesep xls_filename '.xls'];
|
||||||
delete(filename)
|
end
|
||||||
end
|
if isfile(filename)
|
||||||
|
delete(filename)
|
||||||
|
end
|
||||||
|
if ~ispc && ~isoctave && matlab_ver_less_than('9.0') % See above
|
||||||
|
writetable(array2table(xlsmat,'VariableNames',Header), filename);
|
||||||
|
else
|
||||||
|
writetable(array2table(xlsmat,'VariableNames',Header), filename, 'Sheet', 'Regimes');
|
||||||
end
|
end
|
||||||
writetable(array2table(xlsmat,'VariableNames',Header), filename, 'Sheet', 'Regimes');
|
|
||||||
|
|
|
@ -206,8 +206,8 @@ else
|
||||||
0.480506381923643
|
0.480506381923643
|
||||||
-0.111002148299648
|
-0.111002148299648
|
||||||
1.000000000000000];
|
1.000000000000000];
|
||||||
if max(abs(BETA' - good)) > 1e-14
|
if max(abs(BETA' - good)) > 2e-14
|
||||||
error(['sum of BETA'' - good was: ' num2str(sum(abs(BETA - good)))]);
|
error(['sum of BETA'' - good was: ' num2str(sum(abs(BETA' - good)))]);
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,14 +21,14 @@ M.orig_maximum_lag = 2;
|
||||||
caller = 'INITVAL';
|
caller = 'INITVAL';
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
options.series = "ds";
|
options.series = 'ds';
|
||||||
ds1 = histvalf_initvalf(caller, M, options);
|
ds1 = histvalf_initvalf(caller, M, options);
|
||||||
|
|
||||||
failed_tests = my_assert(failed_tests, all(all(ds1 == ds)), 'basic test');
|
failed_tests = my_assert(failed_tests, all(all(ds1 == ds)), 'basic test');
|
||||||
num_tests = num_tests + 1;
|
num_tests = num_tests + 1;
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
options.series = "ds1";
|
options.series = 'ds1';
|
||||||
options.first_obs = 2;
|
options.first_obs = 2;
|
||||||
ds1 = histvalf_initvalf(caller, M, options);
|
ds1 = histvalf_initvalf(caller, M, options);
|
||||||
failed_tests = my_assert(failed_tests, ds1.init == dates('2Y'), ...
|
failed_tests = my_assert(failed_tests, ds1.init == dates('2Y'), ...
|
||||||
|
@ -36,7 +36,7 @@ failed_tests = my_assert(failed_tests, ds1.init == dates('2Y'), ...
|
||||||
num_tests = num_tests + 1;
|
num_tests = num_tests + 1;
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
options.series = "ds";
|
options.series = 'ds';
|
||||||
options.first_obs = 2;
|
options.first_obs = 2;
|
||||||
options.last_obs = 9;
|
options.last_obs = 9;
|
||||||
ds1 = histvalf_initvalf(caller, M, options);
|
ds1 = histvalf_initvalf(caller, M, options);
|
||||||
|
@ -47,7 +47,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ...
|
||||||
num_tests = num_tests + 2;
|
num_tests = num_tests + 2;
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
options.series = "ds";
|
options.series = 'ds';
|
||||||
options.last_obs = 9;
|
options.last_obs = 9;
|
||||||
ds1 = histvalf_initvalf(caller, M, options);
|
ds1 = histvalf_initvalf(caller, M, options);
|
||||||
failed_tests = my_assert(failed_tests, ds1.init == dates('1Y'), ...
|
failed_tests = my_assert(failed_tests, ds1.init == dates('1Y'), ...
|
||||||
|
@ -57,7 +57,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ...
|
||||||
num_tests = num_tests + 2;
|
num_tests = num_tests + 2;
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
options.series = "ds";
|
options.series = 'ds';
|
||||||
options.first_obs = 2;
|
options.first_obs = 2;
|
||||||
options.last_obs = 9;
|
options.last_obs = 9;
|
||||||
options.nobs = 8;
|
options.nobs = 8;
|
||||||
|
@ -69,7 +69,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ...
|
||||||
num_tests = num_tests + 2;
|
num_tests = num_tests + 2;
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
options.series = "ds";
|
options.series = 'ds';
|
||||||
options.last_obs = 9;
|
options.last_obs = 9;
|
||||||
options.nobs = 8;
|
options.nobs = 8;
|
||||||
ds1 = histvalf_initvalf(caller, M, options);
|
ds1 = histvalf_initvalf(caller, M, options);
|
||||||
|
@ -80,7 +80,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ...
|
||||||
num_tests = num_tests + 2;
|
num_tests = num_tests + 2;
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
options.series = "ds";
|
options.series = 'ds';
|
||||||
options.first_obs = 2;
|
options.first_obs = 2;
|
||||||
options.last_obs = 9;
|
options.last_obs = 9;
|
||||||
options.nobs = 7;
|
options.nobs = 7;
|
||||||
|
@ -98,7 +98,7 @@ end
|
||||||
num_tests = num_tests + 1;
|
num_tests = num_tests + 1;
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
options.series = "ds";
|
options.series = 'ds';
|
||||||
options.first_obs = 0;
|
options.first_obs = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -113,7 +113,7 @@ end
|
||||||
num_tests = num_tests + 1;
|
num_tests = num_tests + 1;
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
options.series = "ds";
|
options.series = 'ds';
|
||||||
options.last_obs = 11;
|
options.last_obs = 11;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -17,7 +17,11 @@ ylabels = char(percent,percent,percent,level);
|
||||||
figtitle = 'Simulated variables';
|
figtitle = 'Simulated variables';
|
||||||
legendlist = cellstr(char('Piecewise Linear','Linear'));
|
legendlist = cellstr(char('Piecewise Linear','Linear'));
|
||||||
|
|
||||||
options_.TeX=1;
|
if isoctave || ~matlab_ver_less_than('8.4')
|
||||||
|
% For some unknown reason, MATLAB R2014a crashes with TeX labels
|
||||||
|
% when -nodisplay is passed (as in the testsuite)
|
||||||
|
options_.TeX=1;
|
||||||
|
end
|
||||||
occbin_graph;
|
occbin_graph;
|
||||||
occbin_graph c_hat b_hat y_hat;
|
occbin_graph c_hat b_hat y_hat;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue