필터 지우기
필터 지우기

How do I get the lengths of each entry in a cell array without using a loop

조회 수: 11 (최근 30일)
How can I generate a vector with one entry for the length of each vector in a cell array without using a loop. e.g.
>> ca={1:4,1:9,3:15}
ca =
1×3 cell array
{1×4 double} {1×9 double} {1×13 double}
I want a vector with [4 9 13]
Obviously I could do :
>> for i=1:length(ca);lca(i)=length(ca{i});end
>> lca
lca =
4 9 13
But I have an aversion to using a loop for something like this.

채택된 답변

madhan ravi
madhan ravi 2019년 1월 25일
cellfun(@length,ca)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by