MATLAB: Access the row and col of a matrix

maltlab

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

Best Answer

>> N = 6; % your input
>> [col,row] = ind2sub(size(A),N)
col = 3
row = 2
>> val = A(row,col)
val = 16