MATLAB: The value assigned to variable ‘total’ might be unused

matlab functionmean

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

Best Answer

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