Index in position 1 is invalid. Array indices must be positive integers or logical values.
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2020-9-30
What is min(changeink) and max(changeink) ?
What shows up for
unique(mod(changeink,1))
回答(1 个)
Cris LaPierre
2020-9-30
编辑:Cris LaPierre
2020-9-30
Your values are not integers. For example, what value should rat_ink(79.7,1) return? Valid indices are 1, 2, 3, etc.
4 个评论
Cris LaPierre
2020-9-30
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))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!