필터 지우기
필터 지우기

Check for repeated values in two cell arrays in matlab

조회 수: 4 (최근 30일)
Maria
Maria 2014년 8월 4일
편집: Azzi Abdelmalek 2014년 8월 4일
I have 2 cells with 5 columns and I want to verify whether there are no repetitions in the values of the 1st columns. For example:
a={ 701 452 8 407 31
1037 110 14 873 93
*7985* 881 20 16 69
9420 481 9 191 95}
b={4220 308 118 464 24
*7985* 112 58 37 19
9639 61 29 96 21
9999 34 16 89 37}
In the 3rd row of a & in the 2nd row of b the values of the first column are equal . In that case I would like to obtain a new variable that identifies the lines in which the values are the same.
ab={3 2}
Can someone help me? Thanks

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 8월 4일
편집: Azzi Abdelmalek 2014년 8월 4일
a={ 701 452 8 407 31
1037 110 14 873 93
7985 881 20 16 69
9420 481 9 191 95}
b={4220 308 118 464 24
7985 112 58 37 19
9639 61 29 96 21
9999 34 16 89 37}
a1=[a{:,1}]
b1=[b{:,1}]
[ii,ii]=find(ismember(a1,b1))
[jj,jj]=find(ismember(b1,a1))
out={ii' jj'}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by