[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vectorise matrix slice extraction
From: |
Rob Mahurin |
Subject: |
Re: vectorise matrix slice extraction |
Date: |
Fri, 27 Feb 2009 10:41:52 -0500 |
On Feb 27, 2009, at 8:59 AM, Francesco Potorti` wrote:
Is there a way to efficiently remove the for loop in this assignment?
for jj = length(pple):-1:1
llk(:,:,:,jj) = ll(:,:,:,pple(jj),tple(jj));
endfor
Maybe try
s = size(ll);
s1 = 1:s(1); # etc.
llk( s1,s2,s3, 1:numel(pple) ) =
reshape( ll(s1,s2,s3, pple, tple), [s(1:3), numel(pple)] );
Not tested.
Cheers,
Rob
--
Rob Mahurin
Department of Physics and Astronomy
University of Tennessee 865 207 2594
Knoxville, TN 37996 address@hidden