Borrar filtros
Borrar filtros

How to append Struct?

36 visualizaciones (últimos 30 días)
Rounak Saha Niloy
Rounak Saha Niloy el 16 de Nov. de 2022
Comentada: Rounak Saha Niloy el 16 de Nov. de 2022
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;

Respuesta aceptada

Matt J
Matt J el 16 de Nov. de 2022
Editada: Matt J el 16 de Nov. de 2022
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 comentario
Rounak Saha Niloy
Rounak Saha Niloy el 16 de Nov. de 2022
Thanks, I appreciate it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by