How to remove empty fields from a struct?

When I load a matlab file, I am getting a struct with fields as below:
a =
struct with fields:
bt: {[1×1 struct] [] [] [] [1×1 struct] [1×1 struct]}
I would like to delete the empty fields in between. How do I do that and save the file without changing any structure to it?
but I got this error:
Dot indexing is not supported for variables of this type.

回答 (1 件)

Stephen23
Stephen23 2019 年 6 月 28 日

0 投票

a.bt(cellfun('isempty',a.bt)) = []

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

2019 年 6 月 27 日

回答済み:

2019 年 6 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by