Path: news.mathworks.com!not-for-mail
From: "us " <us@neurol.unizh.ch>
Newsgroups: comp.soft-sys.matlab
Subject: Reading data into matlab
Date: Fri, 27 Jul 2007 17:24:01 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 28
Message-ID: <f8d9nh$p4m$1@fred.mathworks.com>
References: <f8b7sr$gbt$1@fred.mathworks.com> <f8bjea$jnq$1@fred.mathworks.com> <f8bko6$a7o$1@fred.mathworks.com> <f8d3qo$6ov$1@fred.mathworks.com> <f8d5qg$4i$1@fred.mathworks.com> <f8d7v4$bva$1@fred.mathworks.com> <f8d8kf$mcq$1@fred.mathworks.com> <f8d928$5l2$1@fred.mathworks.com>
Reply-To: "us " <us@neurol.unizh.ch>
NNTP-Posting-Host: webapp-00-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1185557041 25750 172.30.248.35 (27 Jul 2007 17:24:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 27 Jul 2007 17:24:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:421463


us:
<SNIP incomplete code

a more frugal solution now looks like this

% your data file
     fnam='foo.txt'; % <- your file!
% the engine
     a=textread(fnam,'%s','delimiter','','whitespace','');
     an=cell(numel(a),1); 
for  i=1:numel(a) 
     [an{i,1:3}]=sscanf(a{i},'%f,'); 
end 
     ixs=[an{:,2}]==4;
     ib=strfind(ixs,[0,1])+1;
     ie=strfind(ixs,[1,0]);
if   ~isempty(ib)
     nb=numel(ib);
     rb=cell(nb,1);
for  i=1:nb
     rb{i,1}=reshape(cat(1,an{ib(i):ie(i),1}).',4,[]).';
end
end
% the result 
     type(fnam);
     rb{:}

us