Is it possible to do same without for loop?
lengthboundaries=zeros(length(boundaries),1);
for i=1:length(boundaries)
lengthboundaries(i)=length(boundaries{i});
end

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 5 Aug. 2017

1 Stimme

lengthboundaries = cellfun(@length,boundaries);

2 Kommentare

Jan
Jan am 5 Aug. 2017
Bearbeitet: Jan am 5 Aug. 2017
+1. Or even faster:
lengthboundaries = cellfun('length', boundaries);
Ilida Suleymanova
Ilida Suleymanova am 5 Aug. 2017
Wow. thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by