Index in position 2 exceeds array bounds (must not exceed 1)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Julia Williams
am 30 Jul. 2019
Kommentiert: Julia Williams
am 30 Jul. 2019
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 Kommentare
Akzeptierte Antwort
Guillaume
am 30 Jul. 2019
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!