'Subscript indices must either be real positive integers or logicals... and they are.' Why the error?

I keep getting the following error when I try to plot to vectors of data and it doesn't make sense to me. Does anyone know why this is happening?
x =
1.0e+04 *
3.592304700000000
3.631143000000000
3.684712000000000
3.722212000000000
3.767748400000000
3.833372000000000
3.886942000000000
3.935166400000000
4.007484799999999
4.075794999999999
>> y
y =
2.052695376905927
2.116785788400099
2.203573844584633
2.266329782184324
2.342437651581077
2.450590377072377
2.538714605463729
2.628180700403267
2.745678639284237
2.865853118409325
>> isreal(x)
ans =
1
>> isreal(y)
ans =
1
>> plot(x,y)
Subscript indices must either be real positive integers or logicals.

2 Comments

Likely, you have a variable named plot in the workspace, so MATLAB thinks you are trying to index into the variable and not call the plot function. Therefore the error is about an index and not a function input.

Answers (0)

This question is closed.

Asked:

on 30 Jul 2015

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!