Any idea why Matlab could behave like this?
>> sum([0 0 0]) Subscript indices must either be real positive integers or logicals. >> sum([1 1 1]) an
you've overridden the function sum and now it is considered a local variable
sum
sum = s(1, 1);
thus you are hiding sum as function.
Change the variable name and do
clear sum
.