Index in position 2 exceeds array bounds (must not exceed 1)
2 次查看(过去 30 天)
显示 更早的评论
x = [(indexbase(1,1)) (indexknuckle1(1,1)) (indexknuckle2(1,3))]
y = [(indexbase(1,2)) (indexknuckle1(1,2)) (indexknuckle2(1,2))]
z =[(indexbase(1,3)) (indexknuckle1(1,3)) (indexknuckle2(1,3))]
scatter3(x,y,z);
indexbase =
-23.5270
69.2678
20.9718
indexknuckle1 =
2.2664
45.3186
92.6306
Anyone know why I am getting this error? I am calling indexbase/knuckle1/2 from workspace variable I have saved. Thanks for any help you can offer!
0 个评论
采纳的回答
Guillaume
2019-7-30
a) get rid of all the unnecessary brackets that make it harder to read your expressions
x = [indexbase(1,1), indexknuckle1(1,1), indexknuckle2(1,3)] %was a 3 meant here for indexknuckle2?
y = [indexbase(1,2), indexknuckle1(1,2), indexknuckle2(1,2)]
z = [indexbase(1,3), indexknuckle1(1,3), indexknuckle2(1,3)]
b) if you're using vectors, then use 1D notation instead of 2D notations, particularly if you're not careful about whether your vectors are row or column vectors:
x = [indexbase(1), indexknuckle1(1), indexknuckle2(3)] %was a 3 meant here for indexknuckle2?
y = [indexbase(2), indexknuckle1(1), indexknuckle2(2)]
z = [indexbase(3), indexknuckle1(3), indexknuckle2(3)]
This will fix your problem.
The cause for the error, is that indexknuckle1(1,2) asks for row 1 column 2 of vectors that have 3 rows and only one column. indexknuckle1(2,1) was meant here, but if you use 1D indexing it works regardless.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!