MATLAB: How can I add all the 7 values of ‘a’ in the following loop

for loop

for i=1:7
a=A(1,1)*Z(1,i)
end

Best Answer

Note: Pre-allocation is important when a loop is used.
change
A(1,1)
to
A(i)