Hello everybody !
You helped me a lot these last days, thanks !
I come up today with another question, concerning preallocation.
Let's consider 2 versions of code :
% a and b some matrix 1D
tab = zeros(length(a), length(b)); % PREALLOCATION
for x_idx = 1:length(a) for y_idx = 1:length(b) tab(x_idx, y_idx) = a(x_idx) * b(y_idx); endend
And :
% x and y some matrix 1D
tab = zeros(length(x), length(y)); % PREALLOCATIONtab = a' .* b;
I am wondering if I really need preallocation in the second version, because I don't access to every key of an "growing up" array, but I use Matlab vectorization..
So I think I can write (without loosing in terms of perf, and event do a bargain) :
% x and y some matrix 1Dtab = a' .* b;
Am I right ?
Robin.
Best Answer