From: Walter Roberson <>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird (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$> <f7om7m$dvb$> <gi9c71$c2a$> <WlX1l.5935$%z5.391@newsfe09.iad> <gib8ib$p3p$>
In-Reply-To: <gib8ib$p3p$>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 24
Message-ID: <Vwa2l.55622$uS1.14182@newsfe19.iad>
X-Trace: newsfe19.iad 1229534389 (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: comp.soft-sys.matlab:507570

Matt wrote:
> Walter Roberson <> 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

.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)?