Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Preallocating structures
Date: Tue, 17 Mar 2009 20:22:01 +0000 (UTC)
Organization: Mitre Corp
Lines: 22
Message-ID: <gpp0p9$glf$1@fred.mathworks.com>
References: <gpovld$r76$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1237321321 17071 172.30.248.37 (17 Mar 2009 20:22:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 17 Mar 2009 20:22:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2318
Xref: news.mathworks.com comp.soft-sys.matlab:525639

"Kian " <kian.torab@utah.edu> wrote in message <gpovld$r76$1@fred.mathworks.com>...
> I'm trying to preallocate structures, but I can't find any information on how to do this.
> 
> Here's what I have:
> 
> myStructure.Channels.Units.Trial
> 
> There should be 96 channels, 5 units, 100 trials, and then an array of spike times for each trial.
> 
> For example, myStructure.Channel(4).Unit(2).Trial(27)
> 
> should give me all the spike times that occurred on channel 4 by unit 2 and on the 27th trial.
> 
> I'd like to preallocate my structure so the code runs faster. I know how to preallocate a single simple structure: 
> 
> myStructure(10) = struct('fieldname', []);
> 
> Any idea?

You might also be interested in this:

http://blogs.mathworks.com/loren/2008/02/01/structure-initialization/