MATLAB Answers

Couldn't find what's wrong

1 view (last 30 days)
IBM watson
IBM watson on 22 Mar 2019
Commented: madhan ravi on 22 Mar 2019
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.

  0 Comments

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 22 Mar 2019
Edited: madhan ravi on 22 Mar 2019
q = 3;
b = find( cellfun( @numel, a ) == q )
%or
b = find( cellfun( 'prodofsize', a ) == q )

  2 Comments

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

Sign in to comment.

More Answers (0)

Tags


Translated by