How to find out the value of a matrix corresponding row and column?

조회 수: 1 (최근 30일)
Boni_Pl
Boni_Pl 2019년 8월 30일
댓글: Boni_Pl 2019년 8월 30일
Hello I have index of a matrix x=[1;2;3] & y=[1;1;2]. Now how to check what value in which index of the matrix.Suppose the matrix is z=[0 4;5 6;1 0]. Now how can I check what is the value of (x,y) index.Please help.

채택된 답변

Stephen23
Stephen23 2019년 8월 30일
Use sub2ind:
>> x = [1;2;3];
>> y = [1;1;2];
>> z = [0,4;5,6;1,0];
>> z(sub2ind(size(z),x,y))
ans =
0
5
0

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by