I need help!! ;-)
I need a constant and global structure array in a parfor-loop in a function file. Since the parallel computing toolbox does not allow global and persistent variables in a parallel parfor-loop I struggle with this issue. ... The access to the structure array shall be very fast, so it is not possible to save it in a file and to read from it in the loop. It is important to mention that the structure array cannot a function input argument!!
Any ideas to solve this problem? :-)
Best regards!
Michael
> I need a constant and global structure array in a parfor-loop in a function
> file. Since the parallel computing toolbox does not allow global and
> persistent variables in a parallel parfor-loop I struggle with this
> issue. ... The access to the structure array shall be very fast, so it is not
> possible to save it in a file and to read from it in the loop.
Does this help:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/248094#639592
?
> It is important to mention that the structure array cannot a function input
> argument!!
I'm not sure I understand this restriction - why can't you pass the structure
array into a function? (That's what's happening internally in various places to
end up in the body of your parfor loop).
Cheers,
Edric.
Many thanks!
Michael
Edric M Ellis <eel...@mathworks.com> wrote in message <ytwbpp8...@uk-eellis-deb4-64.mathworks.co.uk>...
> Many thanks for the link! I saw this thread before I have send my
> request. ... In principle this method would work, but I am afraid of this
> concept because memory will be temporarily allocated in each iteration in the
> subfunction, which might time inefficient. Better would be a CONSTANT variable
> (structure array). Maybe you know how to create a constant structure array?
Passing a large variable into a function in MATLAB doesn't necessarily cause
memory allocation because MATLAB uses copy-on-write to implement value
semantics. See part 2 of this FAQ answer:
http://matlabwiki.mathworks.com/MATLAB_FAQ#Can_MATLAB_pass_by_reference.3F
perhaps that helps.
Cheers,
Edric.
Cheers,
Michael
Edric M Ellis <eel...@mathworks.com> wrote in message <ytw7hzu...@uk-eellis-deb4-64.mathworks.co.uk>...