www.pudn.com > snippets(1).rar > read_exp.m, change:2009-10-12,size:753b


function [data, class] = read_exp(filename)
%
% read image data and class information from text file

%data = cell(0);
%class = cell(0);

fid = fopen(filename,'r');
if fid<0
  error('READ_EXP: cannot open file');
end
content = textscan(fid,'%s%d');
fclose(fid);

curr_sub = 0;
curr_ex = 1;

for u = 1:size(content{1},1)
  
  if strcmp(content{1}{u}, 'frames')
      continue;
  end
  
  if strcmp(content{1}{u}, 'subject')
    curr_sub = curr_sub+1;
    curr_ex = 1;
  else
    data{curr_sub}{curr_ex} = [content{1}{u} '.p.L.v1.mat'];
    class{curr_sub}(curr_ex) = content{2}(u);
    curr_ex = curr_ex+1;
    data{curr_sub}{curr_ex} = [content{1}{u} '.p.R.v1.mat'];
    class{curr_sub}(curr_ex) = content{2}(u);    
    curr_ex = curr_ex+1;
  end

end