I have two structs, one called AllPositions_CA with X and Y fields containing this type of layout:
X Y
1×17051 double 1×17051 double
1×17267 double 1×17267 double
1×17579 double 1×17579 double
1×17971 double 1×17971 double
1×17959 double 1×17959 double
1×17947 double 1×17947 double
1×17854 double 1×17854 double
1×641 double 1×641 double
1×17918 double 1×17918 double
1×17544 double 1×17544 double
This structure has a length 114 (I have only shown 10)
I have a second structure called PositionA which has X and Y fields containing this type of layout:
X Y
1×42 double 1×42 double
1×44 double 1×44 double
1×43 double 1×43 double
1×43 double 1×43 double
1×44 double 1×44 double
1×43 double 1×43 double
1×43 double 1×43 double
1×43 double 1×43 double
1×44 double 1×44 double
1×42 double 1×42 double
This particular structure has length of 18000 (I have only shown 10)
I want to be able to take ALL X and Y values as pairs in AllPositions_CA and compare them to X and Y pair values in PositionA and remove any values which are present in PositionA but are not present in AllPositions_CA and put them into a new structure whilst retaining the layout of the structure PositionA. For example after the removal of some values from PositionA the new structure will look like:
X Y
1×40 double 1×40 double
1×39 double 1×39 double
1×41 double 1×41 double
1×40 double 1×40 double
1×42 double 1×42 double
1×41 double 1×41 double
1×39 double 1×39 double
1×40 double 1×40 double
1×43 double 1×43 double
1×38 double 1×38 double
I have looked into intersect and setdiff but cannot get my head around how to loop one structure through another to find differences and return the desired final layout as above.
Thanks
Best Answer