How to compare the content of 2 cells and get the content from cell1 column1?

조회 수: 2 (최근 30일)
chocho
chocho 2018년 5월 28일
답변: Nikhil Negi 2018년 5월 29일
hello guys, i have 2 cells and i want to compare cell1 (of size 172*1) column1 with cell2 (of size 30644*2) column2. If they are equal i would like to get their content from cell2 column1.
Note that the rows of cell1 column1 may occur multiple times in cell2 column2.
inputs:
Expected outputs:
  댓글 수: 2
Nikhil Negi
Nikhil Negi 2018년 5월 28일
Hello, are the contents of cell 2 column 2 just repetitions of the contents of cell 1 column 1??
chocho
chocho 2018년 5월 28일
Nikhil Negi yes repetitions and some other extra things which do not exist in the cell1 column and i just focused on the common contents.
So you can say all the content of cell1 column1 exist on cell2 column2 with repetitions

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

답변 (2개)

KSSV
KSSV 2018년 5월 28일
Read about ismember.
  댓글 수: 4
chocho
chocho 2018년 5월 28일
i use it but i'cant find the expected outputs i want we can use isequal and strcmp too but i fail to get the right format
KSSV
KSSV 2018년 5월 29일
ismember is simple to use...attach your data....

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


Nikhil Negi
Nikhil Negi 2018년 5월 29일
Hello chocho,
you can use temp=ismember(cell1,cell2(:,2)) ans=all(temp); if ans=1 then cell1 is a subset of cell2 column 2(your required condition) and if ans=0 then your condition is not satisfied

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by