The value assigned to variable 'total' might be unused

function ret = Mean(Set)
total = 0;
for i = 1:length(Set)
total += Set(i);
end
ret = total / length(Set);
end

 Accepted Answer

This line is not a valid Matlab syntax
total += Set(i);
You need to change it to:
total = total + Set(i);

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!