matlab蒙特卡洛求 代码parfor,如何在我的matlab脚本(临时变量)中使用'parfor'?(How can I use 'parfor' in my matlab script (tem...

I have this code:

Result = {};

% parfor k=1:1:3

for k=1:1:3

% parfor j=1:1:10

for j=1:1:10

time = 1000*j;

[A, B, C] = test (time,k,j);

Result = cat(1,Result,{k,j,time,A,B,C});

end

end

Each 'k' iteration takes about 20 minutes, because the function 'test' is heavy. As you see, the variable 'Result' is a cell matrix where each row contains the result of the function along with other variables.

If I change the first 'for loop' for 'parfor' the result is firstly a warning (Warning: The temporary variable Result will be cleared at the beginning of each iteration of the parfor loop) and finally an error (Reference to a cleared variable Result).

As additional data, the two loops can be run in parallel as the 'test' function is independent. The problem is to store the result.

What would you do to solve this?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值