help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Slicing submatrices -- more graceful/ vectorized way?


From: forkandwait
Subject: Re: Slicing submatrices -- more graceful/ vectorized way?
Date: Sun, 22 Aug 2010 23:15:09 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Jaroslav Hajek <highegg <at> gmail.com> writes:

> cntyagesex = reshape(data(:,end), 39*36, []);
> idx = 1:36;
> for ii = 1:39
>  idx += 36;
>  x{ii} = cntyagesex(starti:endi,:);
> endfor

I think we mean 

cntyagesex = reshape(data(:,end), 39*36, []);
idx = 1:36;
for ii = 1:39
  x{ii} = cntyagesex(idx,:);
  idx += 36;
endfor

but otherwise, adding 36 to the index matrix is exactly what I was looking for. 
 
It shifts it perfectly to the next section. I put the update at the end of the 
for loop or it misses the first section.

Tx!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]