Path: news.mathworks.com!not-for-mail
From: "Lorenzo Guerrasio" <lorenzo.guerrasio@email.it>
Newsgroups: comp.soft-sys.matlab
Subject: Re: vector operation, selecting chunks
Date: Fri, 20 Mar 2009 17:35:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 23
Message-ID: <gq0k46$hct$1@fred.mathworks.com>
References: <gq0fo1$l89$1@fred.mathworks.com> <gq0j8i$if9$1@fred.mathworks.com>
Reply-To: "Lorenzo Guerrasio" <lorenzo.guerrasio@email.it>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1237570502 17821 172.30.248.37 (20 Mar 2009 17:35:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 20 Mar 2009 17:35:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1371978
Xref: news.mathworks.com comp.soft-sys.matlab:526477


I've so much to learn
thanks a lot

"Matt Fig" <spamanon@yahoo.com> wrote in message <gq0j8i$if9$1@fred.mathworks.com>...
> One approach using old-school vectorization:
> 
> 
> % Some data:
> v=round(rand(100,1)*9);
> M=[1,4;7,8;80,93];
> 
> % The engine:
> L = size(M,1);
> R = cumsum(M(:,2)-M(:,1)+1);
> IDX = ones(1,R(end));
> IDX(1) = M(1,1);
> IDX(1 + R(1:end-1)) = M(2:L,1) - M(1:L-1,2);
> v2 = v(cumsum(IDX));
> 
> 
> 
> 
> uujj$_ed^|aW0eYW[[OuukuCXj[fue_f6[k^du]WXucYWelec^;WbeoWbW|