Path: news.mathworks.com!not-for-mail
From: "Titus" <titus.edelhofer@mathworks.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Best way to loop through unknown structure
Date: Wed, 15 Aug 2007 11:19:35 +0200
Organization: The MathWorks, Inc.
Lines: 33
Message-ID: <f9ugf5$9v2$1@fred.mathworks.com>
References: <f9ufl4$tb$1@fred.mathworks.com>
NNTP-Posting-Host: de-edelhoft-x.ac.mathworks.de
X-Trace: fred.mathworks.com 1187169574 10210 172.16.75.150 (15 Aug 2007 09:19:34 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 15 Aug 2007 09:19:34 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
Xref: news.mathworks.com comp.soft-sys.matlab:424001



"Karl Trumstedt" <karltru@gmail.com> schrieb im Newsbeitrag 
news:f9ufl4$tb$1@fred.mathworks.com...
> Here is what I am using right now. I am wondering if there
> is any other way to do it. Say that I want to convert each
> structure field to one regular variable. What is the best
> method do you think?
>
> x = struct(...)
>
> if isstruct(x)
>    s = fieldnames(x);
>    for i=1:length(s)
>        assignin('caller', char(s(i)), x.(char(s(i)));
>    end
> end
>
> / Karl
> Developer @ Lundin Mining AB
> http://www.lundinmining.com/index.php
> Developer @ Kolonn AB http://www.kolonn.se

Hi,
the only suggestion I would have is to use a simpler call
into the cell arrays:
        assignin('caller', s{i}, x.(s{i}));
but that's all. Perhaps you could tell us, why you would
need something like that?

Titus