From: Matt Fig on 6 Aug 2010 17:26 Perhaps I misunderstand, but if the nans are only in the second page wouldn't it be much faster to just do: [r,c] = find(isnan(A(:,:,2))); for ii = 1:length(r) A(r(ii),c(ii),2) = (A(r(ii),c(ii),1)+A(r(ii),c(ii),3))/2; end
From: Matt Fig on 6 Aug 2010 17:49 Even if there are nans in the other dimensions, I would think this would still be faster: IDX = 1:3; B = A; % To preserve the original. Not necessary. for jj = 1:3 S = IDX(~(IDX==jj)); [r,c] = find(isnan(B(:,:,jj))); for ii = 1:length(r) B(r(ii),c(ii),jj) = (B(r(ii),c(ii),S(1))+B(r(ii),c(ii),S(2)))/2; end end
First
|
Prev
|
Pages: 1 2 Prev: mxGetData gets garbage Next: Loading specific variables from multiple '-mat' files |