write.m 2.49 KB
Newer Older
 Houtan Bastani committed Apr 02, 2013 1 2 3 4 5 ``````function o = write(o, fid, dates, precision) %function o = write(o, fid, dates, precision) % Write Table Row % % INPUTS `````` Houtan Bastani committed Apr 10, 2013 6 7 8 ``````% o [series] series object % dates [dynDates] dates for series slice % precision [float] precision with which to print the data `````` Houtan Bastani committed Apr 02, 2013 9 10 ``````% % OUTPUTS `````` Houtan Bastani committed Apr 10, 2013 11 ``````% o [series] series object `````` Houtan Bastani committed Apr 02, 2013 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 ``````% % SPECIAL REQUIREMENTS % none % Copyright (C) 2013 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 . %% Validate options passed to function assert(fid ~= -1); assert(isa(dates, 'dynDates')); assert(isint(precision)); %% Validate options provided by user assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ... '@series.write: must provide data as a dynSeries'); assert(ischar(o.color), '@series.write: color must be a string'); `````` 43 44 ``````assert(ischar(o.tableNegColor), '@series.write: tableNegColor must be a string'); assert(ischar(o.tablePosColor), '@series.write: tablePosColor must be a string'); `````` Houtan Bastani committed May 13, 2013 45 ``````assert(islogical(o.showTableMarkers), '@series.write: showTableMarkers must be a string'); `````` 46 ``````assert(islogical(o.tableAlignRight), '@series.write: tableAlignRight must be a string'); `````` Houtan Bastani committed Apr 02, 2013 47 48 49 50 51 52 `````` %% Write Output dataString = ['%.' num2str(precision) 'f']; precision = 10^precision; fprintf(fid, '%% Table Row (series)\n'); `````` 53 ``````if o.tableAlignRight `````` Houtan Bastani committed Apr 03, 2013 54 55 `````` fprintf(fid, '\\multicolumn{1}{r}{'); end `````` Houtan Bastani committed Apr 03, 2013 56 ``````fprintf(fid, '%s', o.data.tex{:}); `````` 57 ``````if o.tableAlignRight `````` Houtan Bastani committed Apr 03, 2013 58 59 `````` fprintf(fid, '}'); end `````` Houtan Bastani committed Apr 02, 2013 60 61 62 63 64 65 ``````data = o.data(dates); data = data.data; for i=1:size(data,1) thisCellData = round(data(i)*precision)/precision; fprintf(fid, ' &'); `````` Houtan Bastani committed May 13, 2013 66 `````` if o.showTableMarkers `````` Houtan Bastani committed Apr 02, 2013 67 `````` if thisCellData < 0 `````` 68 `````` fprintf(fid, '\\color{%s}', o.tableNegColor); `````` Houtan Bastani committed Apr 02, 2013 69 `````` elseif thisCellData > 0 `````` 70 `````` fprintf(fid, '\\color{%s}', o.tablePosColor); `````` Houtan Bastani committed Apr 02, 2013 71 72 73 74 75 76 `````` end fprintf(fid, '['); end fprintf(fid, dataString, thisCellData); `````` Houtan Bastani committed May 13, 2013 77 `````` if o.showTableMarkers `````` Houtan Bastani committed Apr 02, 2013 78 79 80 81 82 `````` fprintf(fid, ']'); end end fprintf(fid, ' \\\\\n\n'); end``````