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):
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:5| Question number:26.5
All Answers
total answers (1)
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