matrix index in Parfor loop

1 Ansicht (letzte 30 Tage)
rahman
rahman am 25 Jan. 2015
Bearbeitet: Matt J am 25 Jan. 2015
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

Antworten (1)

Matt J
Matt J am 25 Jan. 2015
Bearbeitet: Matt J am 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;

Kategorien

Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by