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

조회 수: 5 (최근 30일)
Mamoru Mabuchi
Mamoru Mabuchi 2021년 11월 5일
댓글: Mamoru Mabuchi 2021년 11월 6일
下記のような空([])の値を含む構造体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!