help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatically Combining Structures


From: Paul Kienzle
Subject: Re: Automatically Combining Structures
Date: Tue, 25 Apr 2006 21:31:25 -0400


On Apr 25, 2006, at 9:35 AM, Bill Denney wrote:

Hi,

Is there a way to automatically combine structures? What I'm wanting to
do is something like:

a.c = 1;
a.d = 2;
b.e = 3;
b.f = 4;
g = combine(a, b)

g =
{
  c = 1
  d = 2
  e = 3
  f = 4
}

Do I have to write the function, or is it included as part of
octave(-forge)?

Maybe you could turn this into a function?

octave> s = struct('a',1,'b',2,'e',4); t = struct('a',2,'c',3,'d',5);
octave> struct([[fieldnames(s);fieldnames(t)],[struct2cell(s); struct2cell(t)]]'{:})
ans =
{
  a = 2
  b = 2
  c = 3
  d = 5
  e = 4
}

- Paul



reply via email to

[Prev in Thread] Current Thread [Next in Thread]