a=cell(1,3)
a{2}= [2 4 5]
for i=1:3
if numel(a{i})==3
b=cellfun(@(q) q==a(i),a,'un',1)
end
end
I tried to find index of the matrix which have a certain number of elements in a cell.

 채택된 답변

madhan ravi
madhan ravi 2019년 3월 22일
편집: madhan ravi 2019년 3월 22일

1 개 추천

q = 3;
b = find( cellfun( @numel, a ) == q )
%or
b = find( cellfun( 'prodofsize', a ) == q )

댓글 수: 2

IBM watson
IBM watson 2019년 3월 22일
thanks but what is q=3 for ?
madhan ravi
madhan ravi 2019년 3월 22일
Refers to number of elements you can change it accordig to your desire.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

질문:

2019년 3월 22일

댓글:

2019년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by