sub2ind problem for matrix

조회 수: 2 (최근 30일)
Mohammad Golam Kibria
Mohammad Golam Kibria 2011년 7월 4일
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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 7월 4일
idx=sub2ind(size(I),r(:,1),r(:,2))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by