Q:

Vectorize this code! Write one assignment statement that will accomplish exactly the same thing as the given code (assume that the variable vec has been initialized):

0

Vectorize this code! Write one assignment statement that will accomplish exactly the same thing as the given code (assume that the variable vec has been initialized): 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

result = 0;

for i = 1:length(vec)

 result = result + vec(i);

end

>> result = sum(vec)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now