access the row and col of a matrix

조회 수: 4 (최근 30일)
Elysi Cochin
Elysi Cochin 2017년 4월 21일
편집: Stephen23 2017년 4월 21일
i have a matrix
A = [11 12 13
14 15 16
17 18 19];
now i take a value 6... how can i get the value there and and row and column....
eg: value = 16
row = 2
col = 3

채택된 답변

Stephen23
Stephen23 2017년 4월 21일
편집: Stephen23 2017년 4월 21일
>> N = 6; % your input
>> [col,row] = ind2sub(size(A),N)
col = 3
row = 2
>> val = A(row,col)
val = 16

추가 답변 (2개)

dbmn
dbmn 2017년 4월 21일
2 Possibilities
Easiest: row column
A(2,3)
Second possibility (by element count)
A(8)

Eng. Fredius Magige
Eng. Fredius Magige 2017년 4월 21일
call it as: call=A(2,3)

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by