MATLAB: Please Speed UP This Algoritm!!!

algorithmMATLABmatrix

hi i'd like to know if there's is a way to speed up this algoritm where:, lphi is a vector of 120 elements, IN4 is a matrix of 4×8192, aaa is a 3D matrix of 4x8192x120
for k = 1:lphi;
B4(k,:) = sum(IN4.*aaa(:,:,k));
end
B = sum(abs(B4).^2,2);
thanks, i don't know if in c++ it work faster any ideas?

Best Answer

B4 = reshape(permute(bsxfun(@tims,IN4,aaa),[3 1 2]),size(aaa,3),[]);
B = sum(abs(B4).^2,2);