sub2ind problem for matrix

2 次查看(过去 30 天)
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