1function [Q, A0, Aplus, Zeta] = load_flat_file(file_tag) 2%function [Q, A0, Aplus, Zeta] = load_flat_file(file_tag) 3% Loads file saved by save_draws option of ms_simulation. 4% 5% INPUTS 6% file_tag: the file tag used with ms_simulation 7% 8% OUTPUTS 9% Q: Q matrix 10% A0: A0 matrix 11% Aplus: A+ matrix 12% Zeta: Zeta matrx 13% 14% SPECIAL REQUIREMENTS 15% none 16 17% Copyright (C) 2013 Dynare Team 18% 19% This file is part of Dynare. 20% 21% Dynare is free software: you can redistribute it and/or modify 22% it under the terms of the GNU General Public License as published by 23% the Free Software Foundation, either version 3 of the License, or 24% (at your option) any later version. 25% 26% Dynare is distributed in the hope that it will be useful, 27% but WITHOUT ANY WARRANTY; without even the implied warranty of 28% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29% GNU General Public License for more details. 30% 31% You should have received a copy of the GNU General Public License 32% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 33 34Q = []; 35A0 = []; 36Aplus = []; 37Zeta = []; 38 39try 40 headerfid = fopen(['est_flat_header_' file_tag '.out'], 'r'); 41catch 42 error(['Can''t find est_flat_header_' file_tag '.out']) 43end 44headerfile=textscan(headerfid, '%s'); 45fclose(headerfid); 46flatfile = dlmread(['est_flat_' file_tag '.out'], ' '); 47 48headerfile = headerfile{:}; 49for i=1:length(headerfile) 50 line = char(headerfile{i}); 51 indob = strfind(line, '['); 52 indcb = strfind(line, ']'); 53 indop = strfind(line, '('); 54 indcp = strfind(line, ')'); 55 indc = strfind(line, ','); 56 if isempty(indob) 57 name = line(1:indop-1); 58 dim3 = []; 59 else 60 name = line(1:indob-1); 61 dim3 = line(indob+1:indcb-1); 62 end 63 row = line(indop+1:indc-1); 64 col = line(indc+1:indcp-1); 65 66 if isempty(dim3) 67 eval([name '(' row ',' col ') = ' num2str(flatfile(i)) ';']); 68 else 69 eval([name '(' row ',' col ',' dim3 ') = ' num2str(flatfile(i)) ';']); 70 end 71end 72