[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Struct arrays, column names, syntactic sugar...
From: |
forkandwait |
Subject: |
Struct arrays, column names, syntactic sugar... |
Date: |
Fri, 9 Apr 2010 16:50:23 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Is there a way to reference groups of fields in a struct array by name?
For example, consider A:
A = cell2struct ({'Peter', 'Hannah', 'Robert';
185, 170, 168},
{'Name','Height'}, 1);
A(1)
We can do A(1) and get Peter's data, or we could do [A(:).Name] and (sort of)
get a list of names (though I would like a column of text rather than a
concatenated row), but it would be super awesome to also be able to do something
like
A(1:2).(Name,Age)
and get a 2 x 2 cell array with the appropriate data.
Any thoughts? Are there common tricks to do this?
The ONLY thing I miss about R is being able to reference heterogeneous data
through lists of column names....
Tx
- Struct arrays, column names, syntactic sugar...,
forkandwait <=