bespectacled
bespectacled

Reputation: 2901

Mode function in Matlab

I was trying to use the mode function in matlab over an array of numbers (some negative negative present in this array). But when I do

mode(this_array)

i get "Attempted to access mode(-1); index must be a positive integer or logical".

The following is my piece of code:

for row=1:K,
    ind = index(row);
    label = trY(ind);
    i = i + 1;
end % for

y = mode(label); // gives error esp. when the array contains only one negative value

Thanks.

Upvotes: 0

Views: 780

Answers (1)

Jacob
Jacob

Reputation: 34601

There is a good chance that you have a variable named mode in your program.

Upvotes: 3

Related Questions