Remove a row from an array

3 ビュー (過去 30 日間)
Hadley Acrh
Hadley Acrh 2019 年 11 月 6 日
コメント済み: Hadley Acrh 2019 年 11 月 7 日
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);

採用された回答

the cyclist
the cyclist 2019 年 11 月 6 日
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 件のコメント
Hadley Acrh
Hadley Acrh 2019 年 11 月 7 日
Yes, that is what I was trying to describe. Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by