Given a random vector
v = rand(10,1);
if you want the sum of its elements, do NOT use a loop
s = 0;
for ii = 1:10
s = s + v(ii);
end
but use the vectorized capability of the sum() function
s = sum(v);
Functions like sum(), mean(), prod() and others, have the ability to operate ...