How to remove empty line from struct?
51 ビュー (過去 30 日間)
表示 古いコメント
Hello every one
I have struct D with two fields: index
sequence [ ]
D :
1 [1 2 4 5]
[] []
3 [1 2 4 5]
4 [1 2 3 5]
I want to remove the empty line from D and become
1 [1 2 4 5]
3 [1 2 4 5]
4 [1 2 3 5]
thank you
0 件のコメント
回答 (1 件)
Yazan
2021 年 8 月 17 日
D.f1 = [1 2 3 4 5];
D.f2 = [];
% structure with 2 fields
D
% get fields
fields = fieldnames(D)
% remove empty fields
D = rmfield(D, fields(structfun(@isempty, D)))
3 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!