On Fri, Aug 20, 2010 at 1:03 PM, forkandwait
<address@hidden> wrote:
Is there a more graceful way to handle this? I always mess up my index
calculations ("starti" and "endi" below) and it pisses me off. Another
constraint is that I would like to avoid 3-d matrices, though maybe they are the
best solution
(I find that code that uses more than 2-d becomes brittle when
other people try to maintain it -- hence the cellarray "x" to store each county.)
Well, I don't know a one-liner but, you can at least be rid of the index calculations if you become more favorable toward 3D:
cntyagesex = reshape(data(:,end), 39, 36, []) ;
for ii = 1:39
x(ii) = squeeze(cntyagesex(ii,:,:)) ;
endfor
cntyagesex = reshape(cntyagesex, 29*36,[]) ;
I have also wanted an easy way to slice up a matrix into a cell array (for use in parcellfun) but I don't know how to do that.
--judd