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: 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" <> wrote in message <k255l9$7bn$>...
> "Andreas Lobinger" <> wrote in message
> news:k2555d$5a5$

> > this is tricky. Maybe i'm missing some basics?
> See the second item in the Tips section of the documentation for STRUCT:
> 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]

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