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: Combine parts of strucure array matrix
Replies: 1   Last Post: Feb 22, 2013 9:50 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
dpb

Posts: 8,181
Registered: 6/7/07
Re: Combine parts of strucure array matrix
Posted: Feb 22, 2013 9:50 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 2/22/2013 2:22 AM, Tim wrote:
> Hi!
> Starting point: Structure array
> fData(1).val=ones(2)
> fData(2).val=2*ones(2)
>
> I would like to combine for example the first row of each fData.val like:
> [fData(1).val(:,1) , fData(2).val(:,1)]
> but in a more elegant way without accessing each entry seperately. It
> works to combine like:
> [fData.val]
> but I can't choose just parts of the .val matrix.


Ayup, ML specifically documents the limitation of not being able to
reference subindices of fields for more than a single field index
expression. A significant limitation, agreed...

If you have to stick w/ the structure and need the above, you'll have to
either use a loop and retrieve each structure array component one at a
time or do the full concatenation as above and then select the
row/column desired (your above example says 'row' but is actually the
first column as written).

v = [fData.val]; v=v(1,:); % first row

Superficially doesn't seem as though there's a problem in the indexing
other than similar to cells so don't know why there's not a generalized
form available--perhaps it's in the development stage still...

--





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

[Privacy Policy] [Terms of Use]

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