MATLAB: Question of applying sum() to the matrix with zero values

sum

my matrix is X=[1 0 0 ;0 0 0;0 9 0](actual matrix is larger than this and having less values more zoros) my question is ,when applying sum(X),it gives error message "??? Subscript indices must either be real positive integers or logicals."

Best Answer

You've probably used sum as a variable in your code. Try this
clear sum
X=[1 0 0 ;0 0 0;0 9 0]
sum(X)