1
votes

I was having an issue with the bar function, where it would return either the error "Subscript indices must either be real positive integers or logicals" or "Index exceeds matrix dimensions."

To make sure everything was running okay, I copied and pasted one of the examples from "help bar" and entered it:

subplot(3,1,2), bar(0:.25:1,rand(5),1)

and I get the following response from MATLAB:

Warning: Integer operands are required for colon operator when
used as index 
Subscript indices must either be real positive integers or
logicals.

Now, I'm not really sure where to go from here short of completely reinstalling MATLAB.

Any suggestions? I've already tried restarting MATLAB/rebooting my computer.

Thanks!

EDIT: When I first start MATLAB, the bar function example works correctly. Then, after I import old data, the example bar function no longer works.

Any ideas?

1

1 Answers

3
votes

You are importing a variable called bar, so that when you run bar(0:.25:1,rand(5),1), it thinks you are indexing the variable bar rather than providing an input argument to a function called bar.

Run whos bar to see the variable.