find element in cell
2 ビュー (過去 30 日間)
古いコメントを表示
Dear all, I've problem with the cell,
a= {[67 8 33] [1 2 3 5] [2 88 5] [3 66 7 90] [3] [66 78 12 1 44 6 77 3]},
how to find each cell have number 3. answer expect it is:
b= {[1 2 3 5] [3 66 7 90] [3] [66 78 12 1 44 6 77 3]}
thanks all
0 件のコメント
回答 (2 件)
KSSV
2017 年 7 月 12 日
a= {[67 8 33] [1 2 3 5] [2 88 5] [3 66 7 90] [3] [66 78 12 1 44 6 77 3]} ;
b= {[1 2 3 5] [3 66 7 90] [3] [66 78 12 1 44 6 77 3]} ;
iwant = cell([],1) ;
count = 0 ;
for i = 1:length(a)
if any(a{i}==3)
count = count+1 ;
iwant{count} = a{i} ;
end
end
iwant
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!