%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This file is part of NS2DDV. % % % % Copyright(C) 2011-2018 C. Calgaro (caterina.calgaro@math.univ-lille1.fr) % % E. Creusé (emmanuel.creuse@math.univ-lille1.fr) % % T. Goudon (thierry.goudon@inria.fr) % % A. Mouton (alexandre.mouton@math.univ-lille1.fr) % % % % NS2DDV 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. % % % % NS2DDV 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 % % NS2DDV. If not, see . % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function[headers, diags] = read_logfile(namefile) % INPUT % namefile Name of the log file to be read % % OUTPUT % headers The list of diagnostic names % diags The diagnostics within the log file A = importdata(namefile); if ~iscell(A) headers = strsplit(A.textdata{1}, ' - '); diags = A.data; else % Problem while using importdata routine : A is returned as a cell array of strings [nlines,ncols] = size(A); if (nlines > 1) % The file contains headers and data % Headers are contained in the first line headers = strsplit(A{1}, ' - '); ncols = size(headers,2); % Data are contained in the following lines in string format diags = []; for i=2:nlines textdiags = strtrim(strsplit(A{i,:}, ' ')); % WARNING : textdiags may contain empty strings linediags = []; for j=1:size(textdiags,2) if ~strcmp(textdiags{1,j}, '') linediags = [linediags, str2num(textdiags{1,j})]; end end diags = [diags; linediags]; end else % The file does not contain any numerical data message = sprintf('The log file %s does not contain any numerical data\n', namelogfile); for i=1:nlines message = strcat(message, sprintf('%s\n', A{i,1})); end error(message); end end end