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 assign multiple structure elements at once
Replies: 5   Last Post: Nov 17, 2012 10:01 AM

Advanced Search

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

Posts: 1
Registered: 11/15/12
how to assign multiple structure elements at once
Posted: Nov 15, 2012 1:15 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I'm trying to assign multiple values to second element of a field of multiple structure elements. Better I give you an example to explain that:

let's say the values are = 1,2,3
structure is = a
field is = s

then the result should look like this:
a(1).s(2) = 1
a(2).s(2) = 2
a(3).s(2) = 3

I need something similar to deal. However with deal function I can only set the first element of field 's' as shown below:

b = num2cell(1:3)
[a(1:3).s] = deal(b{:})
which gives me
a(1).s = 1
a(2).s = 2
a(3).s = 3

Could you please help me?

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.