How to find elements in common between two cell arrays?

2 views (last 30 days)
Gargolla9
Gargolla9 on 13 Jun 2022
Commented: David Hill on 13 Jun 2022
Hi everyone! I have two cell arrays (the ones called B_90 and B_120 that I have attached in the Data.zip file). I would like to know how to find the elements in common between them. For example the first cell of B_90 is a 554x2 double variable and its first element is the point of coordinates (102;62). I would like to know if in B_120 there is a point of coordinates (102;62) in any of the cells within it. Then I would like to iterate this check procedure for every element in every cell within the cell array B_90. Could you help me? Thanks in advance.
  2 Comments
Gargolla9
Gargolla9 on 13 Jun 2022
@Jan sorry, I have made a mistake, I am searching for [120;62]. I have edited my question

Sign in to comment.

Accepted Answer

David Hill
David Hill on 13 Jun 2022
load('B_90.mat');
A=B;
load('B_120.mat');
I=intersect(A{1},B{1},'rows');%as an example points in common between A{1} and B{1}
  2 Comments
David Hill
David Hill on 13 Jun 2022
load('B_90.mat');
A=cell2mat(B);
load('B_120.mat');
B=cell2mat(B);
I=intersect(A,B,'rows');

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!