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.

 Akzeptierte Antwort

madhan ravi
madhan ravi am 22 Mär. 2019
Bearbeitet: madhan ravi am 22 Mär. 2019

1 Stimme

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

2 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by