Using ind2sub in two different arrays
1 次查看(过去 30 天)
显示 更早的评论
I have two arrays and i want to exclude the zeros from the first array(A) and then take the equivalent indices from array B.
A=[0 1 2; 2 1 4; 0 1 5];
B=[1 2 3; 2 4 2; 2 3 5];
[X,Y]=ind2sub(size(A),find(A>0))
Anew=A(X,Y)
Bnew=B(X,Y)
The result of the above is not what i want, Anew and Bnew are now larger than before. What am i doing wrong?
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!