Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe19.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird 2.0.0.18 (Windows/20081105)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to rename a workspace variable in a loop?
References: <f7olca$1mj$1@fred.mathworks.com> <f7om7m$dvb$1@fred.mathworks.com> <gi9c71$c2a$1@fred.mathworks.com> <WlX1l.5935$%z5.391@newsfe09.iad> <gib8ib$p3p$1@fred.mathworks.com>
In-Reply-To: <gib8ib$p3p$1@fred.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 24
Message-ID: <Vwa2l.55622$uS1.14182@newsfe19.iad>
NNTP-Posting-Host: 24.79.146.116
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe19.iad 1229534389 24.79.146.116 (Wed, 17 Dec 2008 17:19:49 UTC)
NNTP-Posting-Date: Wed, 17 Dec 2008 17:19:49 UTC
Date: Wed, 17 Dec 2008 11:20:17 -0600
Xref: news.mathworks.com comp.soft-sys.matlab:507570

Matt wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message <WlX1l.5935$%z5.391@newsfe09.iad>...

>> S = cell2struct(mat2cell(X,size(X,1),size(X,2),ones(1,size(X,3))),num2str((1:size(X,3)).','slice%d'),3);
>> save(OutputFileName,'S', '-struct');

> Well, okay. If you're point was that you don't need to use eval(), then yes.
 
> My point was more that this is an application requiring that arrays be assigned to
> dynamically named variables.

The application only really required dynamically named -fields-. And using dynamically
named -fields- is one of the recommended ways to avoid eval().

> The use of arrays, as encouraged by the FAQ, is not enough here.                             

The FAQ is only as good as its contributors make it. The Matlab Central team welcomes
enhancements.

-- 
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?