Remove a row from an array

3 views (last 30 days)
Hadley Acrh
Hadley Acrh on 6 Nov 2019
Commented: Hadley Acrh on 7 Nov 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);

Accepted Answer

the cyclist
the cyclist on 6 Nov 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 Comment
Hadley Acrh
Hadley Acrh on 7 Nov 2019
Yes, that is what I was trying to describe. Thank you!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!