[Date Index]
[Thread Index]
[Author Index]
Re: structure array equivalent in Mathematica
*To*: mathgroup at smc.vnet.net
*Subject*: [mg67228] Re: [mg67162] structure array equivalent in Mathematica
*From*: Kevin Bowman <kevinbowman at mac.com>
*Date*: Tue, 13 Jun 2006 01:07:27 -0400 (EDT)
*References*: <NDBBJGNHKLMPLILOIPPOAEHIFAAA.djmp@earthlink.net>
*Sender*: owner-wri-mathgroup at wolfram.com
David,
Yes, this is definitely along the lines I was hoping for. Of course,
Part is the primary means of extracting elements of an array.
However, I need a means of assigning names to elements of those
lists. I deal with reasonably large datasets where there may be many
elements in a list and trying to remember that elements of list 78
are quality flags is not very effective.
I guess the difference here is that the original data is still in one
nested list with the pure functions there to extract the appropriate
components whereas with a structure array the data itself is already
organized in that fashion.
I will see where I can go with this approach.
Thanks,
Kevin
On Jun 11, 2006, at 12:01 PM, David Park wrote:
> Kevin,
>
> Generally you would use Part. But if you wanted to make a more
> convenient
> usage you could do something like the following. First create some
> sample
> data.
>
> data = Table[{p[i], t[i], wv[i]}, {i, 1, 5}];
>
> observation[i_] := Part[data, i]
> pressure := Part[#, 1] &
> temperature := Part[#, 2] &
> watervapor := Part[#, 3] &
>
> pressure@observation[3]
> p[3]
>
> watervapor@observation[1]
> wv[1]
>
> temperature /@ data
> {t[1], t[2], t[3], t[4], t[5]}
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
>
> From: kevin_jazz [mailto:kevinbowman at mac.com]
To: mathgroup at smc.vnet.net
>
> Like many people I imagine, I'm transitioning to Mathematica from a
> background in another system.
> One of the common data types is the structure array. Let's say I have
> an observational data set that includes pressure, temperature, and
> water vapor as a function of altitude. So, in pseudo-code I might
> define a structure as
>
> observation = {pressure: float(100), temperature: float(100),
> water_vapor: float(100)}
>
> I could then access the elements of this observation as
>
> observation.pressure
> observation.temperature, etc.
>
> Furthermore, I could aggregate these observations into a larger
> list, e.g.
> obs_day = {observation, observation, observation}
> to be accessed as
> obs_day[1].pressure for the first element (assuming 1-index).
>
> Now, the list in Mathematica is quite powerful and I think can be
> set-up in a similar fashion.
>
> So my question is how is the structure array commonly implemented in
> Mathematica or its equivalent?
>
> If there is a previous thread (I looked but didn't find any) on the
> topic or in the Mathematica book or Mathematica Journal that I missed,
> feel free to point me in that direction.
>
> Many thanks,
>
> Kevin Bowman
> Jet Propulsion Laboratory
>
>
Prev by Date:
**Re: structure array equivalent in Mathematica**
Next by Date:
**Re: Using Mathlink to export arrays**
Previous by thread:
**Re: structure array equivalent in Mathematica**
Next by thread:
**Re: structure array equivalent in Mathematica**
| |