Borrar filtros
Borrar filtros

Index in position 2 exceeds array bounds (must not exceed 1)

1 visualización (últimos 30 días)
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!

Respuesta aceptada

Guillaume
Guillaume el 30 de Jul. de 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.
  1 comentario
Julia Williams
Julia Williams el 30 de Jul. de 2019
Thank you this worked perfectly! I appreciate the explaination as well!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by