필터 지우기
필터 지우기

How to append Struct?

조회 수: 34 (최근 30일)
Rounak Saha Niloy
Rounak Saha Niloy 2022년 11월 16일
댓글: Rounak Saha Niloy 2022년 11월 16일
I have 3 structures as follows-
ABC.x=1;
ABC.y=2;
ABC.z=3;
DEF.p=1;
DEF.q=2;
GHI.m=1;
GHI.n=2;
How can I append the values from the last two structs into the first struct? Infact, what I am looking for is somethiong like this-
ABC.x=1;
ABC.y=2;
ABC.z=3;
ABC.p=1;
ABC.q=2;
ABC.m=1;
ABC.n=2;

채택된 답변

Matt J
Matt J 2022년 11월 16일
편집: Matt J 2022년 11월 16일
One way:
ABC.x=1;
ABC.y=2;
ABC.z=3;
DEF.p=10;
DEF.q=20;
GHI.m=100;
GHI.n=200;
args=[namedargs2cell(ABC), namedargs2cell(DEF),namedargs2cell(GHI)];
ABC=struct(args{:})
ABC = struct with fields:
x: 1 y: 2 z: 3 p: 10 q: 20 m: 100 n: 200
  댓글 수: 1
Rounak Saha Niloy
Rounak Saha Niloy 2022년 11월 16일
Thanks, I appreciate it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by