How do I get the value at a particular index?

172 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2020-3-1
Yes the techniques there are good, except I would not use the diag() one

请先登录,再进行评论。

回答(1 个)

Siriniharika Katukam
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)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by