I hope you can help me out here, I have a speed problem in matlab with the following code:
%Example Definition
bf = 80;
sam = 10000;
dim = 300;
a = rand(bf, sam, dim);
T = rand(bf, sam, dim);
x = repmat(rand(1, sam, dim), [bf 1 1]);
%Calculation
E = zeros(size(T, ndims(T)));
dist = zeros(bf, sam);
a = repmat( a, [ 1 1 dim ]);
for i = 1:dim
for j = 1:dim
dist = x(:,:,j) .* T(:,:,i);
E(i,j) = sum(sum(a(:,:,i) .* (0.5 * dist), 2), 1);
end
end
These 3 diminsional arrays are quite big (like 80x10000x300), so that there is a high computation time to calculate this 'E' matrix. I've already tried to vectorize it, but i have no a good idea how to do that without going into the memory limit (16 GB).
Any idea how to speed this up ?