Hello !
Let us take 3 vectors 1D :
vectors L, M and N
% let us take L, M, N, 3 matrix 1D
for Lidx = 1:length(L) for Midx = 1:length(M) for Nidx = 1:length(N) tab(Lidx, Midx, Nidx) = L(Lidx)*M(Midx)*N(Nidx); end endend
How can I optimize that ?
I found myself a solution :
L_repmat = repmat(L, 1, length(M), length(N));N_3d = permute(N, [3 1 2]);N_3d_repmat = repmat(N_3d, length(L), length(M));vectorized = L_repmat.*N_3d_repmat;
I works nicely, but is there a more optimized way ?
Robin ?
Best Answer