What does this means?

1 visualización (últimos 30 días)
Jose99
Jose99 el 19 de Mzo. de 2023
Editada: Stephen23 el 19 de Mzo. de 2023
i was working on a class assignment and then i found this one operation i found it confussing.
G= [ 1 2 3; 4 5 6; 7 8 9];
H= G([1 3], [1 2]);
what does the function H do to the G matrix?
i tried to change the numbers inside the brackets but it shuffles the elements of the matrix G and i dont understand how it works.
is there any documentation referring to this problem?
  1 comentario
Stephen23
Stephen23 el 19 de Mzo. de 2023
Editada: Stephen23 el 19 de Mzo. de 2023
"what does the function H do to the G matrix?"
Nothing: there is no function H, and that indexing does not change G at all.
H is simply the name of a variable that the result of some indexing is assigned to, i.e. H is an array.
"is there any documentation referring to this problem?"
Of course, see the end of the section Indexing Matrices with Two Subscripts here:
Indexing is a MATLAB superpower. Basic indexing concepts are introduced here:

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 19 de Mzo. de 2023
It returns the elements in from rows 1 and 3 in columns 1 and 2 —
G= [ 1 2 3; 4 5 6; 7 8 9];
H= G([1 3], [1 2])
H = 2×2
1 2 7 8
.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays 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