Remove missing entries from nested cell array
5 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have a cell array which has string arrray inside like for example below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1528656/image.jpeg)
and some of the string array have empty/missing contents:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1528661/image.jpeg)
I would like to remove these empty/missing entries from the overall cell_array (temp_vars).
I tried something like:
temp_vars = temp_vars(~cellfun('isempty',temp_vars))
but did not find a solution yet. Any help would be appreciated.
0 件のコメント
回答 (2 件)
Dyuman Joshi
2023 年 11 月 3 日
temp_vars = temp_vars(~cellfun(@(x) any(ismissing(x)),temp_vars))
4 件のコメント
Image Analyst
2023 年 11 月 3 日
How many does that remove? He wants to "to remove only the first empty".
Dyuman Joshi
2023 年 11 月 3 日
Voss
2023 年 11 月 3 日
% make a cell array of string arrays with some missing elements:
str = ["some",missing,"string"];
C = repmat({str},1,3)
% remove the missing elements:
C = cellfun(@rmmissing,C,'UniformOutput',false)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!