Extracting the values using [row,col]
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Naomi Amuzie
el 4 de Jun. de 2019
Comentada: Naomi Amuzie
el 4 de Jun. de 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
0 comentarios
Respuesta aceptada
Walter Roberson
el 4 de Jun. de 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) );
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!