Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
parfor with structures?

Subject: parfor with structures?

From: Chuck37

Date: 29 Oct, 2012 15:56:08

Message: 1 of 2

Parfor seems painfully stupid for a problem I'm trying to do. It goes like this. Say I have a structure put together for convenience, eg:

struct.a = randn(1,N)
struct.b = randn(1,N)

I want to do something that is absolutely, unquestionable parallel:

function struct = dosomething(struct)
parfor x = 1:N
  struct.a(x) = func(struct.a(x),struct.b(x))
end

MATLAB won't have it. The only way I can make it do the right thing is to pull a and b off the structure, run the parfor and then put it all back together. Is this really true? In real life I don't just have a and b, I have about 10 things, so it's kind of a pain.

Subject: parfor with structures?

From: Edric M Ellis

Date: 29 Oct, 2012 16:09:37

Message: 2 of 2

"Chuck37 " <chuck3737@yahooremovethis.com> writes:

> Parfor seems painfully stupid for a problem I'm trying to do. It goes
> like this. Say I have a structure put together for convenience, eg:
>
> struct.a = randn(1,N)
> struct.b = randn(1,N)
>
> I want to do something that is absolutely, unquestionable parallel:
>
> function struct = dosomething(struct)
> parfor x = 1:N
> struct.a(x) = func(struct.a(x),struct.b(x))
> end
>
> MATLAB won't have it. The only way I can make it do the right thing
> is to pull a and b off the structure, run the parfor and then put it
> all back together. Is this really true? In real life I don't just
> have a and b, I have about 10 things, so it's kind of a pain.

Unfortunately, it is true - the PARFOR machinery does not currently
handle this case. This limitation is described here in the doc:

<http://www.mathworks.com/help/distcomp/advanced-topics.html#bq_tcng-1>

Cheers,

Edric.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us