extract an array from cell with its indexes

조회 수: 1 (최근 30일)
Sohaib Bin Altaf
Sohaib Bin Altaf 2019년 12월 26일
댓글: Sohaib Bin Altaf 2019년 12월 26일
I have a cell array of following type,
clstr= { [] 8 [7,8] [6,8] [6,7] [6,7,8] 5 4 [4,8] [4,7,8] [4,6,7] [4,6,7,8] [4,5] [4,5,8] [4,5,7] }
i have another matrix named ter=[4,5], what i want is to see if clstr has this value and if it has then get the index value of [4,5] from clstr. Which in this case is going to be 13. I have used following command but it doesn't help me with what i need.
cellfun(@(x)(ismember(ter,x)),clstr,'UniformOutput',false)
can anyone help me please.

채택된 답변

Stephen23
Stephen23 2019년 12월 26일
편집: Stephen23 2019년 12월 26일
>> clstr = {[],8,[7,8],[6,8],[6,7],[6,7,8],5,4,[4,8],[4,7,8],[4,6,7],[4,6,7,8],[4,5],[4,5,8],[4,5,7]};
>> ter = [4,5];
>> idx = find(cellfun(@(m)isequal(m,ter),clstr))
idx = 13

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by