필터 지우기
필터 지우기

how to compare the elements of 2 cell arrays and get their rows from cell2?

조회 수: 3 (최근 30일)
chocho
chocho 2017년 5월 15일
댓글: chocho 2017년 5월 15일
Hi Friends, I have 2 cell arrays cell1(1*1) and cell2(1*2) I want to compare the elements of cell1 with cell2 and when all the elements of cell 1 exist in both members of cell2 then get its corresponding row from cell2.
Input:
cell1={gene1;gene2;gene3;gene4;gene5}
cell2={gene1,gene3;gene10,gene100;gene2,gene5}
output
out={gene1,gene3;gene2,gene5}
I have tried isequal and find(ismember) and get empty array.
  댓글 수: 5
chocho
chocho 2017년 5월 15일
@Stephen Cobeldick bro , i already tried intersect but i'm not getting what i want. Actually i want to get the full row from cell 2 and this row should havein its both coulmns elements existed in cell1.
clear all
load('cell1')
load('cell2')
c1 =intersect( PPI_data{:, 1},Stage1Exp10_data{:, 1},'rows');
c2 =intersect(PPI_data{:, 2},Stage1Exp10_data{:, 1},'rows');
D=intersect(c1, c2,'rows');
chocho
chocho 2017년 5월 15일
@Stephen Cobeldick bro, I also tried this code but i want the full row
S= [PPI_data{:, 1} , PPI_data{:, 2}];
[C,ia,ib] = intersect( S, Stage1Exp10_data{:,1},'rows');

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

답변 (1개)

KSSV
KSSV 2017년 5월 15일
cell1={'gene1';'gene2';'gene3';'gene4';'gene5'} ;
cell2={'gene1','gene3';'gene10','gene100';'gene2','gene5'} ;
out={'gene1','gene3';'gene2','gene5'} ;
[ia,ib] = ismember(cell2,cell1) ;
cell2(ia)
  댓글 수: 3
KSSV
KSSV 2017년 5월 15일
load cell1.mat ;
load cell2.mat ;
cell1 = PPI_data ;
cell2 = Stage1Exp10_data{1} ;
cell1 = [cell1{1} cell1{2}] ;
[ia,ib] = ismember(cell2,cell1) ;
cell2(ia)
chocho
chocho 2017년 5월 15일
@KSSV hi bro, Thanks for you reply but I want to get a row.

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

카테고리

Help CenterFile Exchange에서 矩阵和数组에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!