Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!i20g2000prf.googlegroups.com!not-for-mail
From: NZTideMan <mulgor@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to rename a workspace variable in a loop?
Date: Wed, 17 Dec 2008 11:26:20 -0800 (PST)
Organization: http://groups.google.com
Lines: 30
Message-ID: <61c8fc70-2c72-47bc-88f0-2a559d0059a5@i20g2000prf.googlegroups.com>
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> <gibebb$ft8$1@fred.mathworks.com> 
	<gibfac$j94$1@fred.mathworks.com>
NNTP-Posting-Host: 202.78.152.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1229541980 12950 127.0.0.1 (17 Dec 2008 19:26:20 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 17 Dec 2008 19:26:20 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: i20g2000prf.googlegroups.com; posting-host=202.78.152.105; 
	posting-account=qPexFwkAAABOl8VUndE6Jm-9Z5z_fSpR
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) 
	Gecko/2008120122 Firefox/3.0.5,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 bc3
Xref: news.mathworks.com comp.soft-sys.matlab:507593


On Dec 18, 7:10=A0am, "Matt" <mjacobson.removet...@xorantech.com> wrote:
> > for k =3D 1:size(X, 3)
> > =A0 =A0 S.(sprintf('slice%d', k)) =3D X(:, :, k);
> > end
> > save(OutputFileName,'S', '-struct');
>
> > Unless your X has a lot of pages, though, the FOR
> > loop won't have to execute for very long. =A0And IMO it's more easily r=
ead
> > than Walter's two-liner.
>
> It has about 600 pages, but it doesn't matter. The actual execution of th=
e save() command will clearly be the bottleneck here, regardless of the num=
ber of pages.
>
> > The use of an array is insufficient in this case. =A0The use of a combi=
nation
> > of dynamic field names and the -struct flag for SAVE is sufficient to
> > accomplish the goal as you stated: =A0"later you want to load in one sl=
ice at
> > a time for some sort of slice-wise processing."
>
> I don't draw much of a distinction between dynamic field names and dynami=
c variable names. They're about the same in their internal implementation a=
nyway, no?

Seems to me that a .mat file is not appropriate here.
You need a database that allows random access.
I'd use netCDF for such a task, with the page no. having zero
dimension (meaning it can be expanded indefinitely).