From: Andria on
I am having the exact same problem that was posted here by Eoin. Despite the recommendation provided here, I am still not understanding how to tell Matlab that my matrices are not supposed to be sliced. I have 5 or more matrices that are having this problem. They are completely independent of each iteration and I do not want them to be worked on by multiple workers.

I know it is often helpful to include some code, but mine is quite long and I feel like it will create more confusion than it is worth. If any help can be given without seeing any code I would greatly appreciate it. Thank you!



"Eoin " <emullan11(a)qub.ac.uk> wrote in message <huidrl$nuc$1(a)fred.mathworks.com>...
> Edric M Ellis <eellis(a)mathworks.com> wrote in message <ytwfx0ze1e9.fsf(a)uk-eellis-deb5-64.mathworks.co.uk>...
> > "Eoin " <emullan11(a)qub.ac.uk> writes:
> >
> > > I'm using a parfor loop. Within the loop I'd like to create and use an
> > > array. I'd like each iteration of the loop is to create and use its
> > > own array independently, the array is not used outside the parfor
> > > loop, and I never use the index of the parfor loop to index elements
> > > of the array. In this sense it is, to use the parfor documentation
> > > terminology, a 'temporary' varialbe. However as far as I can see
> > > MATLAB only expects to see sliced arrays within a parfor loop, and
> > > because the way in which I use my array breaks the rules of using
> > > sliced arrays MATLAB complains that it can't classify the array. Is
> > > there a way around this problem or a way to assure MATLAB that this is
> > > not intended to be a sliced array and it's use is independent of all
> > > other iterations of the parfor loop so it can treat it as a temporary
> > > variable?
> >
> > It's definitely possible to create and use temporary variables within a
> > PARFOR loop, like so:
> >
> > parfor ii=1:10
> > tmp = rand(ii);
> > x(ii) = sum(tmp(1,:)) + sum(tmp(:,end));
> > end
> >
> > Here, "tmp" is considered temporary. Can you post an example of some
> > code where you are having trouble? (Note that you must not refer to
> > temporary variables after the end of the PARFOR loop)
> >
> > Cheers,
> >
> > Edric.
>
> Thanks Edric,
>
> I've got it working now, initalising the array as you have fixed the problem This was not necessary when using a simple for loop.
>
> Eoin
 | 
Pages: 1
Prev: what does "$" do?
Next: Data Tip Precision