Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to rename a workspace variable in a loop?
Date: Tue, 16 Dec 2008 23:05:05 +0000 (UTC)
Organization: Xoran Technologies
Lines: 10
Message-ID: <gi9c71$c2a$1@fred.mathworks.com>
References: <f7olca$1mj$1@fred.mathworks.com> <f7om7m$dvb$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1229468705 12362 172.30.248.35 (16 Dec 2008 23:05:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 16 Dec 2008 23:05:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:507403


> Don't.  See question 4.6 in the newsgroup FAQ for some of the reasons you shouldn't do this and alternatives to doing this.
> 
> http://matlabwiki.mathworks.com/MATLAB_FAQ

Since there's been some chatter about this topic on several threads, I thought I'd throw in a case where I think there is no recourse but to make dynamically named variables.

I''m in a situation where it would be really great to be able to save a large array X to a .mat file but later to load back only pieces of X into the workspace. Imagine for instance that X is a large 3D image and later you want to load in one slice at a time for some sort of slice-wise processing.

Unfortunately, load() doesn't let you do this. So, the only alternative I can come up with is to save each slice of X to the .mat file as an individual variable, dynamically created using eval().