フィルターのクリア

Remove elements of a cell array if length<200

2 ビュー (過去 30 日間)
Benedict Low
Benedict Low 2017 年 10 月 11 日
コメント済み: OCDER 2017 年 10 月 11 日
Hi,
I have a cell array with elements of different lengths. I would like to remove elements whose length (number of rows) are less than 200. I have a simplified example here
a=randi(10,199,1);
b=randi(10,205,1);
c=randi(10,80,1);
d=randi(10,300,1);
Y={a; b; c; d};
I would like to remove elements of Y whose lengths are <200, such that the cell array becomes
Y={b;d};
I ran this code but all I got was the first value of matrices b and d, while rows 1 and 3 were [ ]
Y2=cellfun(@(x) x(length(x)>=200), Y, 'un', 0);
Would appreciate if anyone can point out where I went wrong.
Thank you.
Ben

採用された回答

OCDER
OCDER 2017 年 10 月 11 日
Y = Y(cellfun(@(x) length(x) >= 200, Y))
  2 件のコメント
Benedict Low
Benedict Low 2017 年 10 月 11 日
Thank you Donald. Perfect.
OCDER
OCDER 2017 年 10 月 11 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by