필터 지우기
필터 지우기

How to find elements in common between two cell arrays?

조회 수: 13 (최근 30일)
Gargolla9
Gargolla9 2022년 6월 13일
댓글: David Hill 2022년 6월 13일
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
Jan
Jan 2022년 6월 13일
The question is not clear yet: You have the column vector [102;62] in the first matrix. Now you search for [120; 60]? Why not [120; 62]?
What is the wanted output?
Gargolla9
Gargolla9 2022년 6월 13일
@Jan sorry, I have made a mistake, I am searching for [120;62]. I have edited my question

댓글을 달려면 로그인하십시오.

채택된 답변

David Hill
David Hill 2022년 6월 13일
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
Gargolla9
Gargolla9 2022년 6월 13일
@David Hill the procedure is right, but can I have something that works automatically for all the cells of A and B? Not only for A{1} and B{1}?
David Hill
David Hill 2022년 6월 13일
load('B_90.mat');
A=cell2mat(B);
load('B_120.mat');
B=cell2mat(B);
I=intersect(A,B,'rows');

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by