ismember for cell arrays of different sizes
9 ビュー (過去 30 日間)
古いコメントを表示
I have a cell array with different sized cells of class double as follows:
bin_list = {[1], [1,7], [1,7], [1,7,9], [2,8], [3], [1,7]}';
I would like to count all the cells that have a 1 in them (eventually nest it within a for loop such that I count all the cells that have a 2,3, and n in them)
0 件のコメント
採用された回答
Davide Masiello
2022 年 10 月 6 日
bin_list = {[1], [1,7], [1,7], [1,7,9], [2,8], [3], [1,7]}'
cellfun(@(x)ismember(1,x),bin_list)
0 件のコメント
その他の回答 (1 件)
Fangjun Jiang
2022 年 10 月 6 日
bin_list = {[1], [1,7], [1,7], [1,7,9], [2,8], [3], [1,7]}';
Const=1;
f=@(x) ismember(Const,x);
cellfun(f,bin_list)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!