構造体から欠損データを削除する

5 次查看(过去 30 天)
Mamoru Mabuchi
Mamoru Mabuchi 2021-11-5
下記のような空([])の値を含む構造体Aから、空のフィールドを取り除いた構造体Bを作成したいです。
どのようにすれば、よろしいでしょうか
   

回答(1 个)

Atsushi Ueno
Atsushi Ueno 2021-11-5
编辑:Atsushi Ueno 2021-11-5
【類似の質問】
A = struct('a',"abc",'b',"def",'c',[])
A = struct with fields:
a: "abc" b: "def" c: []
fn = fieldnames(A);
B = rmfield(A, fn(cellfun(@(c) isempty(A.(c)), fn)))
B = struct with fields:
a: "abc" b: "def"
  1 个评论
Mamoru Mabuchi
Mamoru Mabuchi 2021-11-6
回答ありがとうございます。
解決いたしました。

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 構造体 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!