function ReadFlake(filename)
%function ReadFlake(filename)
%reads datafile created by the fortran program flake
if nargin<1,
    [filename, pathname] = uigetfile('*.rslt','choose an FLAKE-file');
    if isequal(filename,0)|isequal(pathname,0),
       return,
   end,
   filename=[pathname,filename];
end,

datastr=textread(filename,'%s','delimiter','\n','whitespace','','headerlines',1);
vars = strcat(strread(datastr{1},'%s'),',');vars{end}=vars{end}(1:end-1);
fmtstring = strrep(char(ones(1,length(vars))),char(1),'%f');

evalin('caller',['[',strcat(vars{:}),']', '=', 'textread(', '''' filename, ''',', '''',fmtstring, '''', ',''headerlines'', 2, ''delimiter'', '' \t'');']);