Extracting the values using [row,col]

9 ビュー (過去 30 日間)
Naomi Amuzie
Naomi Amuzie 2019 年 6 月 4 日
コメント済み: Naomi Amuzie 2019 年 6 月 4 日
I have successfully found the row and col's in "x" , (a 61x61 double) where the x values in a line match with values in "x".
%rows and columns where the xvalues of the line are the values in x(contour lines)
[row,col] = find(ismembertol(x,xvalues));
Now, I want to use the subscripts/values in [row,col] to extract data for corresponding cells in any other double.
For example, here are five random locations/indexes in my [row,col].
5 31
20 34
61 47
45 59
23 61
I want to find the 5th row and 31st column in z and y.
20th row and 24th column in z and y... etc

採用された回答

Walter Roberson
Walter Roberson 2019 年 6 月 4 日
In the special case that y and z are exactly the same size as x:
idx = find(ismembertol(x,xvalues));
corresponding_y = y(idx);
corresponding_z = z(idx);
In the case that they might not be the same size:
[row,col] = find(ismembertol(x,xvalues));
corresponding_y = y( sub2ind(size(y), row, col) );
corresponding_z = z( sub2ind(size(z), row, col) );
  1 件のコメント
Naomi Amuzie
Naomi Amuzie 2019 年 6 月 4 日
thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by