Remove a row from an array

3 visualizaciones (últimos 30 días)
Hadley Acrh
Hadley Acrh el 6 de Nov. de 2019
Comentada: Hadley Acrh el 7 de Nov. de 2019
I have a two sets of coordinates, and need to exclude one set from the other. Here 'grid' & 'yx' are the two lists. How would I remove all 'xy' coordinates from 'grid'?
x = [1,1,1,1,1,1,2,2,2];
y = [1,1,2,1,1,2,1,1,2];
n = 1:12;
yx = [y',x'];
[gx,gy] = meshgrid(n,n);
gxy=cat(2,gx',gy');
grid = reshape(gxy,[],2);

Respuesta aceptada

the cyclist
the cyclist el 6 de Nov. de 2019
I don't quite understand.
Do you mean that if a row from grid also appears as a row in yx, then that row should be removed from grid? If yes, then ...
grid(ismember(grid,yx,'row'),:) = []
  1 comentario
Hadley Acrh
Hadley Acrh el 7 de Nov. de 2019
Yes, that is what I was trying to describe. Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by