I was doing the following
for i = 1:m,
index = 0;
for j = 1:n,
index = index+values(i,j)*2^(j-1);
if (j==1)
symbol_chip = chip_values(index+1,:);
else
symbol_chip = [symbol_chip chip_values(index+1,:)];
end
end
end
it tells me the following:
symbol_chipmight be growing inside the loop. Consider preallocating for speed.
Any ideas?
Yes. Each time you go around, your
elseifblock is resizingsymbol_chip, which is expensive. Instead, rewrite your code so that you have (say)symbol_chip = zeros(max_size, 1);before the loop. Then, change the contents but not the size ofsymbol_chip.You’ll need to slightly change your approach, but it will be much faster if you do. If you’re not annoyed by the current speed, don’t change anything!