Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: struct prealocation
Replies: 3   Last Post: Nov 6, 2012 1:19 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Barry Williams

Posts: 312
Registered: 6/14/06
Re: struct prealocation
Posted: Nov 6, 2012 1:19 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Michal Kvasnicka" wrote in message <k7asfm$l23$1@newscl01ah.mathworks.com>...
> "Michal Kvasnicka" wrote in message <k7aov7$al6$1@newscl01ah.mathworks.com>...
> > How can I prealocate structure to eliminate allocation overhead during computation?
> >
> > Example:
> > s ... size 1x10 struct
> > s.x ... size 1x1 double
> > s.y ... size 1x1 double
> > s.z ... size 1x1 double
> >
> > Thanks in advance, Michal

>
> Well, I use this structure initialization:
> s(10).x = [];
> s(10).y = [];
> s(10),z = [];
>
> with good performance.


So what's your question? When you grow the variables, do s(10).x, s(10).y and s(10).z remean scalars? If no, then you're not preallocating those variables in way that will speed up your program when it executes.
Barry



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.