matrix index in Parfor loop

1 次查看(过去 30 天)
rahman
rahman 2015-1-25
编辑: Matt J 2015-1-25
Hi all. for code I write below, I want to use Parfor but MATLAB report an Error for definition t(s):ts(s)+a as the index of matrix b. Does anyone have any Idea help me ?
for s=1:e
b( s, t(s):ts(s)+a ) = ...
end

回答(1 个)

Matt J
Matt J 2015-1-25
编辑:Matt J 2015-1-25
You must first pre-align the data vectors b( s, t(s):ts(s)+a ) into the columns of a matrix B. That way, parfor can see that the data pieces are parallel across s and can slice them,
t=t(:).'; %row
s=(1:e);
T=bsxfun(@plus, t(1:e),(0:a).');
S=repmat((1:e),a+1,1);
idx=sub2ind(size(b), S,T);
B=b(idx);
parfor s=1:e
B(:,s)= ...
end
b(idx)=B;

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by