The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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$>...
> "Michal Kvasnicka" wrote in message <k7aov7$al6$>...
> > 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.

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.