フィルターのクリア

How to append Struct?

36 ビュー (過去 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 Center および File ExchangeStructures についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by