sub2ind problem for matrix

2 vues (au cours des 30 derniers jours)
Mohammad Golam Kibria
Mohammad Golam Kibria le 4 Juil 2011
I have a matrix
r =
6 1
5 2
4 3
3 3
2 3
1 2
2 3
3 3
4 3
5 2
6 1
and a matrix I.
I applied
idx=sub2ind(size(I),r)
It shows me the following:
idx =
6 1
5 2
4 3
3 3
2 3
1 2
2 3
3 3
4 3
5 2
6 1
how to get the correct one easily? thanks

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 4 Juil 2011
idx=sub2ind(size(I),r(:,1),r(:,2))

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays 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