How do I get the value at a particular index?

조회 수: 251 (최근 30일)
Zuha Yousuf
Zuha Yousuf 2019년 10월 24일
댓글: Walter Roberson 2020년 3월 1일
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
Siriniharika Katukam 2019년 10월 29일
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