使用并行计算两个for循环

时间:2013-09-28 07:48:32

标签: matlab parallel-processing

在我的程序中(在matlab中)我有两个for循环,我想对这些循环使用并行计算:

#loop a
for i=1:120000
using var2(from the previous iteration (loop b)) and do something
and make var1
end;
#loop b
for j=1:120000
using var1(from the previous iteration(loop a)) and do something
and make var2
end;

我的电脑是双核的。有人帮我吗?

1 个答案:

答案 0 :(得分:1)

只有在使用的变量是独立的情况下才能执行并行计算。有一些方法可以使变量独立,但情况可能并非如此。在你的情况下,它看起来不像,因为变量需要从其他循环输入先前的变量。