access the row and col of a matrix

6 vues (au cours des 30 derniers jours)
Elysi Cochin
Elysi Cochin le 21 Avr 2017
Modifié(e) : Stephen23 le 21 Avr 2017
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

Réponse acceptée

Stephen23
Stephen23 le 21 Avr 2017
Modifié(e) : Stephen23 le 21 Avr 2017
>> N = 6; % your input
>> [col,row] = ind2sub(size(A),N)
col = 3
row = 2
>> val = A(row,col)
val = 16

Plus de réponses (2)

dbmn
dbmn le 21 Avr 2017
2 Possibilities
Easiest: row column
A(2,3)
Second possibility (by element count)
A(8)

Eng. Fredius Magige
Eng. Fredius Magige le 21 Avr 2017
call it as: call=A(2,3)

Catégories

En savoir plus sur Particle & Nuclear Physics dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by