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: struct literal?
Replies: 2   Last Post: Sep 4, 2012 11:38 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Andreas Lobinger

Posts: 12
Registered: 7/29/11
Re: struct literal?
Posted: Sep 4, 2012 11:38 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


"Steven_Lord" <slord@mathworks.com> wrote in message <k255l9$7bn$1@newscl01ah.mathworks.com>...
> "Andreas Lobinger" <andreas.lobinger@nsn.com> wrote in message
> news:k2555d$5a5$1@newscl01ah.mathworks.com...

> > this is tricky. Maybe i'm missing some basics?
> See the second item in the Tips section of the documentation for STRUCT:
> http://www.mathworks.com/help/techdoc/ref/struct.html
> d = struct('freq',[1 1],'RAT',[1 2],'name',{{'a-string','b-string'}})

Many thanks for the quick and correct answer.

btw: this not only shows up in doc, but already in help struct...

To create fields that contain cell arrays, place the cell arrays
within a VALUE cell array. For instance,
s = struct('strings',{{'hello','yes'}},'lengths',[5 3])
creates the 1-by-1 structure
s =
strings: {'hello' 'yes'}
lengths: [5 3]

So this can be considered RTFM on my side. (but: help struct ends with this example, so reordering might be better here...)

s = struct('type',{'big','little'},'color','red','x',{3 4})

Wishing a happy day,

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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2015. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.