Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Vectorizing different parts of the same array
Date: Mon, 6 Oct 2008 21:37:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 31
Message-ID: <gce0dt$9j6$1@fred.mathworks.com>
References: <gcd9os$6vt$1@fred.mathworks.com> <gcdelq$5he$1@fred.mathworks.com> <gcdh8a$3lm$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1223329021 9830 172.30.248.35 (6 Oct 2008 21:37:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 6 Oct 2008 21:37:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870065
Xref: news.mathworks.com comp.soft-sys.matlab:493917


"Theodor Zouk" <rebet4@hotmail.com> wrote in message <gcdh8a$3lm$1@fred.mathworks.com>...
> "Adam " <not.real@email.com> wrote in message <gcdelq$5he$1@fred.mathworks.com>...
> > "Theodor Zouk" <rebet4@hotmail.com> wrote 
> > 
> > > I want to get k(1:n),where n=4096, make some calculation and then store the result in the first row in an matrix..... then jump to k(n+1:2*n),calculated, store the result in the second row in the matrix and then jump to k(2*n+1:3*n) and so on... Can this be vectorized? I have tried... but i dont think u can avoid an for loop here...
> > 
> > can you reshape to 4096xN and work on each column?
> > 
> > ~Adam
> 
> No i can't reshape... because i have a vector.

Wrong!

> My problem is more like: how can i access each element in a part of an vector then store those values (or at best be able to calculate things in parallell) and then continuing to read elements in the same vector from were i stopped reading the first time... 
> 
> I want to vectorize this for example:
> 
> vec=(1:10);
> mat= zeros(5,2);
> k=1;
> 
> for i=1:2:10
>     mat(k,:)= vec(i:i+1);
>     k=k+1;
> end

vec = 1:10 ;
mat = reshape(vec,2,[]).'

Jos