Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

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

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

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: 214
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 1994-2015. All Rights Reserved.