find a row in a multidimensional cell array
이전 댓글 표시
Hi, I have a cell variable as follows, temp =
'FBgn0039563' 'FBgn0259937' [0.6195]
'FBgn0039563' 'FBgn0024733' [0.5698]
'FBgn0039563' 'FBgn0011236' [0.5247]
'FBgn0039563' 'FBgn0053864' [0.5155]
'FBgn0039563' 'FBgn0035951' [0.5781]
'FBgn0039563' 'FBgn0001224' [0.5462]
'FBgn0039563' 'FBgn0002914' [0.5162]
'FBgn0039563' 'FBgn0264492' [0.8405]
'FBgn0039563' 'FBgn0000259' [0.7570]
'FBgn0039563' 'FBgn0004103' [0.5374]
I want to search a key =['FBgn0039563' 'FBgn0264492' [0.8405]] inside temp. I need the row index of key in temp. Is it possible?
Thanks in advance,
Best Regards, Wasim
댓글 수: 1
Wasim Aftab
2017년 9월 26일
편집: Wasim Aftab
2017년 9월 26일
채택된 답변
추가 답변 (2개)
Jan
2017년 7월 4일
Search = {'FBgn0039563' 'FBgn0264492' [0.8405]}
Match = strcmp(temp(:, 1), Search{1}) & ...
strcmp(temp(:, 2), Search{2}) & ...
cat(1, temp{:, 3}) == Search{3};
Index = find(Match);
댓글 수: 3
Wasim Aftab
2017년 7월 5일
Jan
2017년 7월 5일
@Wasim Aftab: And therefore it would be useful, if you explain the needs exactly. In your original question the key was a single row only.
Then:
Match = ismember(temp(:, 1), Search(1, :)) & ...
ismember(temp(:, 2), Search(2, :)) & ...
ismember(cat(1, temp{:, 3}), cat(1, Search{3, :}));
Wasim Aftab
2017년 7월 7일
Andrei Bobrov
2017년 7월 4일
find(all(ismember(temp(:,1:2),key(1:2)),2) & ismember([temp{:,3}]',key{3}))
댓글 수: 7
Wasim Aftab
2017년 7월 5일
Andrei Bobrov
2017년 7월 5일
편집: Andrei Bobrov
2017년 7월 5일
:)
find(all(ismember(temp(:,1:2),key(:,1:2)),2) & ismember([temp{:,3}]',[key{:,3}]))
Wasim Aftab
2017년 7월 7일
Andrei Bobrov
2017년 7월 7일
Thank you Wasim!
Wasim Aftab
2017년 9월 26일
Andrei Bobrov
2017년 9월 26일
[l,ii] = ismember(temp,key,'rows');
Wasim Aftab
2018년 2월 2일
편집: Wasim Aftab
2018년 2월 2일
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!