reporting: make zerotol work for both graphs and reports

time-shift
Houtan Bastani 2014-05-22 19:01:48 +02:00
parent bc2274e08a
commit 0f61ae941a
3 changed files with 30 additions and 11 deletions

View File

@ -36,7 +36,7 @@ dataString = sprintf('%%.%df', precision);
precision = 10^precision;
data = dser(dates);
data = data.data;
data = setDataToZeroFromZeroTol(o, data);
for i=1:size(data,1)
fprintf(fid, '&');
if o.tableShowMarkers

View File

@ -0,0 +1,28 @@
function d = setDataToZeroFromZeroTol(o, ds)
%function d = setDataToZeroFromZeroTol(o, ds)
% Copyright (C) 2014 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/>.
d = ds.data;
stz = bsxfun(@and, ...
bsxfun(@lt, d, o.zeroTol), ...
bsxfun(@gt, d, -o.zeroTol));
if any(stz)
d(stz) = 0;
end
end

View File

@ -105,16 +105,7 @@ else
ds = o.data(xrange);
end
% if graphing data that is within zeroTol, set to zero, create report_series and
% get line:
thedata = ds.data;
stz = bsxfun(@and, ...
bsxfun(@lt, thedata, o.zeroTol), ...
bsxfun(@gt, thedata, -o.zeroTol));
if any(stz)
thedata(stz) = 0;
end
thedata = setDataToZeroFromZeroTol(o, ds);
fprintf(fid, '%%series %s\n\\addplot', o.data.name{:});
writeLineOptions(o, fid);
fprintf(fid,'\ntable[row sep=crcr]{\nx y\\\\\n');