Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


dpb
Posts:
9,259
Registered:
6/7/07


Re: Combine parts of strucure array matrix
Posted:
Feb 22, 2013 9:50 AM


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 availableperhaps it's in the development stage still...




