The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to merge two structures?
Replies: 4   Last Post: Jan 4, 2013 5:58 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
james bejon

Posts: 221
Registered: 3/13/10
Re: How to merge two structures?
Posted: Jan 4, 2013 5:58 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

% If you're particularly bothered about not looping, you can always...
clear all
a.a = 1;
a.b = 2;
b.x = 3;
b.y = 4;
pairs = [fieldnames(a), struct2cell(a); fieldnames(b), struct2cell(b)].';
c = struct(pairs{:});

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.