matrix index in Parfor loop
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Matt J
on 25 Jan 2015
Edited: Matt J
on 25 Jan 2015
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;
0 Comments
See Also
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!