
filename = 'xleap2-wiggler-data/xLEAP-II-onaxis/xLEAP-II-2.dat';


%  fid = fopen(filename);
%  ncol = 7;
%  targetstr = '----------------------------------------------------------------------------------';
%  while true
%      [C,pos] = textscan(fid,'%s', 1);
%      if(strcmp(C{1}{1},nls))
%          nlines=nlines+1;
%      end
%      if(strcmp(C{1}{1},targetstr))
%          break;
%      end
%  end
%  array = [];
%  while ~feof(fid)
%      [C,pos] = textscan(fid,'%s', 1);
%  %      display([i,str2double(C{1}{1}),pos])
%      array = [array, str2double(C{1}{1})];
%  end
%  array = reshape(array, [numel(array)/7,7]);
%  fclose(fid);



fid = fopen(filename);
strread = [];
while 1
    cellread = textscan(fid,'%s',1);
    strread = cellread{1}{1};
    if length(strread)>5
        if strcmp(strread(1:5),'-----')
            break;
        end
    end
end
pdata = cell2mat(textscan(fid,'%f%f%f%f%f%f%f'));
fclose(fid);