Index in position 1 is invalid. Array indices must be positive integers or logical values.
3 views (last 30 days)
Show older comments
Hello,
I have tried various combinations of integers and no matter what I seem to do my code won't work.
inkvar=length(changeink)*var(rat_ink(changeink));
I have tried several different combinations including but not limited too:
inkvar=length(changeink)*var(rat_ink(changeink,1),1));
ink_variance=length(changeink)*var(rat_ink(changeink(1,1)*1,2));
I have even tried changing the names of my variables, nothing is working! I don't know what else to do!
changeink is 10x1 and rat_ink is 10x2
3 Comments
Walter Roberson
on 30 Sep 2020
What is min(changeink) and max(changeink) ?
What shows up for
unique(mod(changeink,1))
Answers (1)
Cris LaPierre
on 30 Sep 2020
Edited: Cris LaPierre
on 30 Sep 2020
Your values are not integers. For example, what value should rat_ink(79.7,1) return? Valid indices are 1, 2, 3, etc.
4 Comments
Cris LaPierre
on 30 Sep 2020
You use indices inside indices. I suspect the same thing is going on with rat_ink.
Try the following:
rat_ink(round(changeink),1),1)
var(rat_ink(round(changeink),1),1))
var(round(rat_ink(round(changeink),1)),1))
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!