Finding elements of an arrays having specified index numbers

5 ビュー (過去 30 日間)
Saeid
Saeid 2019 年 6 月 22 日
回答済み: dpb 2019 年 6 月 22 日
If I select a number of elements from an M X N array (which usually follow a pattern) I need to assign the indices of these elements into an nX2 array where the columns 1 and 2 are the row and column numbers of these elements. then I would like to find elements of another M X N array having these index numbers. As an example, I have already marked the red elements in the 17X14 array shown below and now I want to find the elements of another 17 X 14 array having exactly these numbers. How can I do this?
ArrayIndices.png

採用された回答

dpb
dpb 2019 年 6 月 22 日
Given you return the indices in vectors ix and iy, then
V=A(sub2ind(size(A),ix,iy));
where A is the other array and V will be the vector of returned values from those locations. Note, V is a vector, not an array.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by