How do I get the value at a particular index?

257 visualizaciones (últimos 30 días)
Zuha Yousuf
Zuha Yousuf el 24 de Oct. de 2019
Comentada: Walter Roberson el 1 de Mzo. de 2020
So I have indices corresponding to values that I want. Is there a MATLAB function that would allow me to output the values when I input the indices of those values?
  5 comentarios
Walter Roberson
Walter Roberson el 1 de Mzo. de 2020
Yes the techniques there are good, except I would not use the diag() one

Iniciar sesión para comentar.

Respuestas (1)

Siriniharika Katukam
Siriniharika Katukam el 29 de Oct. de 2019
Hi
Consider A as the matrix, and x as indices, then
Values = A(x)
In case you need value of a 2-D matrix, define 'rowMatrix' which has the row indices and 'colMatrix' which has corresponding column indices, then
Values = A(rowMatrix, colMatrix)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by