24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1064  |  回复: 6
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

田山东

捐助贵宾 (著名写手)

[求助] matalb并行parfor为什么这样不行?问题根源找到了!!

谁能帮我看下下面这个matlab并行语句为什么不给结果呢?我的问题就在这里了。
clc;
clear;
matlabpool open local 2
c=0;
parfor j=1:2
    for k=1:4
    b(k)=k+c;
    end
end
matlabpool close
很短几句话,改成for就有结果。奇怪!!怎么解决呢?
回复此楼
everythinghasitsseason.enjoyyourlife.
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★
田山东: 金币+2, ★★★★★最佳答案, 非常感谢啊 2012-12-04 12:29:33
>>clc;
clear;
matlabpool open local 2
c=0;
S=[];
parfor j=1:2
    b=[];
    for k=1:4
    b(k)=k+c;
    end
    S=[S;b];
end
S

S =

     1     2     3     4
     1     2     3     4
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
6楼2012-12-04 11:16:10
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 7 个回答

dbb627

荣誉版主 (著名写手)

【答案】应助回帖


感谢参与,应助指数 +1
jjdg: 金币+1, 感谢说明 2012-12-04 01:06:18
b(k)的索引有问题,在并行循环体内,不允许改变分段变量的维数
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
2楼2012-12-03 16:40:04
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

田山东

捐助贵宾 (著名写手)

引用回帖:
2楼: Originally posted by dbb627 at 2012-12-03 16:40:04
b(k)的索引有问题,在并行循环体内,不允许改变分段变量的维数

能说的再细致点不?你觉得怎么写才是对的?
everythinghasitsseason.enjoyyourlife.
3楼2012-12-03 21:33:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

引用回帖:
3楼: Originally posted by 田山东 at 2012-12-03 21:33:39
能说的再细致点不?你觉得怎么写才是对的?...

你这段程序目的是干什么,不太明白,j这个循环变量有什么用?
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
4楼2012-12-04 10:13:10
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见