How to find arrays in a cell array

2 ビュー (過去 30 日間)
Efstathios Kontolatis
Efstathios Kontolatis 2017 年 1 月 16 日
編集済み: Stephen23 2017 年 1 月 16 日
Hi guys,
I have a cell array(let's say c) consisting of 2D arrays and I want to find all the arrays that(say a is an array) have size(a,1)<5 and throw them away of the cell. How can I do that?
Thanks in advance

採用された回答

James Tursa
James Tursa 2017 年 1 月 16 日
編集済み: James Tursa 2017 年 1 月 16 日
c = your cell array
x = cellfun(@(x)size(x,1)<5,c); % Logical indexes of arrays with 1st dim < 5
c(x) = []; % Delete those elements from the cell array
  1 件のコメント
Efstathios Kontolatis
Efstathios Kontolatis 2017 年 1 月 16 日
Thanks a lot

サインインしてコメントする。

その他の回答 (1 件)

Stephen23
Stephen23 2017 年 1 月 16 日
編集済み: Stephen23 2017 年 1 月 16 日
Faster and simpler than using a function handle:
idx = cellfun('size',c,1)<5;
c(~idx)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by