help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to extract all variables from a structure


From: Andy Buckle
Subject: Re: How to extract all variables from a structure
Date: Thu, 28 Mar 2013 10:34:46 +0000




On 28 March 2013 09:36, Terry Duell <address@hidden> wrote:
Hello All,

I have a nested structure...

s =

  scalar structure containing the fields:

    data ="">
      scalar structure containing the fields:

        w1 =  237.60
        w2 =  244.20
        w3 =  150
        w4 =  3000
        r1 =  14.500
        r2 =  14.500
         .
         .
         .
        and so on

I see that I can use the function "getfield" to extract the structure "data" from the structure "s".
Is there a neat way of extracting all the variables from "data", (ie. so that they are simply unstructured variables) without having to separately reference each?

Cheers,

I don't think it is possible. The best you can do is use fieldnames, and then go through them using getfield. If it's nested and you can't make assumptions about how it's nested, then make it recursive.

--
/* andy buckle */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]