Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: very large array
Date: Tue, 25 Jun 2013 06:32:07 +0000 (UTC)
Organization: Boeing Co
Lines: 38
Message-ID: <kqbdh7$amk$1@newscl01ah.mathworks.com>
References: <kq9hdf$bsa$1@newscl01ah.mathworks.com> <kq9khs$kvi$1@newscl01ah.mathworks.com> <kq9n1f$smu$1@newscl01ah.mathworks.com> <kq9nib$12h$1@newscl01ah.mathworks.com> <kq9r5n$21t$1@speranza.aioe.org> <kqakig$i31$1@newscl01ah.mathworks.com> <kqaumh$4ko$1@speranza.aioe.org> <kqbcna$93q$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1372141927 10964 172.30.248.45 (25 Jun 2013 06:32:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 25 Jun 2013 06:32:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:798146

"Lorenzo Quadri" <quadrilo_sub_r@gmail.com> wrote in message <kqbcna$93q$1@newscl01ah.mathworks.com>...
> dpb <none@non.net> wrote in message <kqaumh$4ko$1@speranza.aioe.org>...
> > On 6/24/2013 6:26 PM, James Tursa wrote:
> > > dpb <none@non.net> wrote in message <kq9r5n$21t$1@speranza.aioe.org>...
> > >>
> > >> While doing it by a loop is _NOT_ the way for large cases, sometimes
> > >> it is handy and time isn't an issue for small array sizes. The way in
> > >> general to do such things is to start at the end and progress
> > >> forwards--that way the lower indices aren't affected by the deleted
> > >> rows...
> > >>
> > >> for i=length(dat):-1:1
> > >> if((sum(dati(i,:))<355) & range(dati(i,:))>20)
> > >> dati(i,:) = [];
> > >> end
> > >> end
> > >
> > > I understand what you are saying about using a loop on small datasets,
> > > but IMO this is never a good way to program in MATLAB, even on small
> > > datasets....
> > 
> > I don't recall saying it was a "good" way...just that it won't be 
> > terribly noticeable on small datasets.
> > 
> > And, yes, no, I'd never program that way in Matlab unless I had some 
> > ulterior motive as in this posting as a pedagogical tool...
> > 
> > --
> 
> I can't do logic discrimination on dataset on loading because is created by an other program as complete array (matlab workspace format). 
> I can iterate the whole dataset and mark zeros the rows I want to delete, but then I've to delete the rows in possible fast way. 

The fastest way is likely what dpb already posted. The vectorized logical index method:

ix=sum(dat,2)<355 & range(dat,2)>20;
dat(ix,:)=[];

James Tursa