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

下記のような空([])の値を含む構造体Aから、空のフィールドを取り除いた構造体Bを作成したいです。
どのようにすれば、よろしいでしょうか
   

Risposte (1)

Atsushi Ueno
Atsushi Ueno il 5 Nov 2021
Modificato: Atsushi Ueno il 5 Nov 2021

0 voti

【類似の質問】
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 Commento

Mamoru Mabuchi
Mamoru Mabuchi il 6 Nov 2021
回答ありがとうございます。
解決いたしました。

Accedi per commentare.

Categorie

Prodotti

Release

R2019b

Richiesto:

il 5 Nov 2021

Commentato:

il 6 Nov 2021

Community Treasure Hunt

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

Start Hunting!