Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Parallel Code

3 views
Skip to first unread message

Shani Gal

unread,
Apr 16, 2012, 1:57:05 PM4/16/12
to
Hi

Can I run this code in parallel?


A1=F(A1,B1)

A2=F(A2,B2)

F is a function, A1 B1 are unrelated to A2 B2

How can I do this ? ( now it runs one after the other)

Thanks

Shani

Matt J

unread,
Apr 16, 2012, 2:32:06 PM4/16/12
to
"Shani Gal" wrote in message <jmhmhh$b01$1...@newscl01ah.mathworks.com>...
======

Instead of having A1,A2, you should have cell variables A{1} and A{2} and similarly for B. Then, you can do this

parfor i=1:2

A{i}=F(A{i},B{i});

end

Shani Gal

unread,
Apr 17, 2012, 1:50:14 AM4/17/12
to
"Matt J" wrote in message <jmhoj6$jbe$1...@newscl01ah.mathworks.com>...
Thanks

is this the only way?

A1 and A2 (also B1 and B2) are matrix of diffrent size, so it is not so simple to have A{i} etc..

Matt J

unread,
Apr 17, 2012, 9:35:06 AM4/17/12
to
"Shani Gal" wrote in message <jmj0am$c3v$1...@newscl01ah.mathworks.com>...
>
>
> is this the only way?
>
> A1 and A2 (also B1 and B2) are matrix of diffrent size, so it is not so simple to have A{i} etc..
===================


I don't see what's complicated. Different sized data is exactly what cell arrays are for:

>> A{1}=rand(2); A{2}=rand(3); A{3}='cats and dogs'

A =

[2x2 double] [3x3 double] 'cats and dogs'
0 new messages