Extracting the values using [row,col]

5 vues (au cours des 30 derniers jours)
Naomi Amuzie
Naomi Amuzie le 4 Juin 2019
Commenté : Naomi Amuzie le 4 Juin 2019
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

Réponse acceptée

Walter Roberson
Walter Roberson le 4 Juin 2019
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) );

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by