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

5 visualizaciones (últimos 30 días)
Mamoru Mabuchi
Mamoru Mabuchi el 5 de Nov. de 2021
Comentada: Mamoru Mabuchi el 6 de Nov. de 2021
下記のような空([])の値を含む構造体Aから、空のフィールドを取り除いた構造体Bを作成したいです。
どのようにすれば、よろしいでしょうか
   

Respuestas (1)

Atsushi Ueno
Atsushi Ueno el 5 de Nov. de 2021
Editada: Atsushi Ueno el 5 de Nov. de 2021
【類似の質問】
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 comentario
Mamoru Mabuchi
Mamoru Mabuchi el 6 de Nov. de 2021
回答ありがとうございます。
解決いたしました。

Iniciar sesión para comentar.

Categorías

Más información sobre 構造体 en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!