|
Many thanks! ... I am always astonished that copy-on-write is working so well! :-) And the suggested idea also works in my case. Nevertheless, I have to criticize that writing a new function, instead of just using a constant global structure array, is non straight forward - at least for me. Would be nice to have more freedom in programming in some cases, ... e.g. I still think that in some cases call-by-reference
(for variables) would be nice - just as an additional degree of freedom ;)
Cheers,
Michael
Edric M Ellis <eellis@mathworks.com> wrote in message <ytw7hzurcor.fsf@uk-eellis-deb4-64.mathworks.co.uk>...
> "Michael" <xyMueller@web.de> writes:
> > Edric M Ellis <eellis@mathworks.com> wrote in message <ytwbpp85pch.fsf@uk-eellis-deb4-64.mathworks.co.uk>...
> >> "Michael" <xyMueller@web.de> writes:
> >> > 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).
>
> > 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.
|