Azzera filtri
Azzera filtri

matrix index in Parfor loop

1 visualizzazione (ultimi 30 giorni)
rahman
rahman il 25 Gen 2015
Modificato: Matt J il 25 Gen 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

Risposte (1)

Matt J
Matt J il 25 Gen 2015
Modificato: Matt J il 25 Gen 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;

Categorie

Scopri di più su Parallel for-Loops (parfor) in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by