Removing rows from arrays in cells using indexing

If I have a cell containing points necessary to create multiple polygons, like this
A = {[2,1; 3,1; 3,3; 4,3; 2,1],[4,1; 5,1; 5,3; 4,3; 4,1]}
A =
1×2 cell array
[5×2 double] [5×2 double]
And a separate matrix containing a bounding polygon
B = [1,2; 7,2; 7,7; 1,7; 1,2];
I want to remove all points in cell A that lie within the bounding polygon,B. I have a cell that identifies all the points within the bounding polygon B, now how do I remove those points from cell A?
idx = {[0; 0; 1; 1; 0],[0; 0; 1; 1; 0]};

 Réponse acceptée

result = cellfun(@(x,y)x(~y,:),A,idx,'uni',false);

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by