how can I change my code for parallel processing?
Afficher commentaires plus anciens
This is my original code without parfor
For i1=1:1:nrr1
disp(i1);
if (varran(i1) < threshold)
labe(i1)=0;
mvqcoder(e)=[meanranr(i1)];
mvqcodeg(e)=[meanrang(i1)];
mvqcodeb(e)=[meanranb(i1)];
e=e+1;
mvqcode=cat(3, mvqcoder, mvqcodeg, mvqcodeb);
else
labe(i1)=1;
[domr]=domsearch(rang1r(i1,:),dompoolr,gsize,ci1r(i1),ci2r(i1),ci3r(i1),msr(i1),mdr,cd1r,cd2r,cd3r,mscr);
[domg]=domsearch(rang1g(i1,:),dompoolg,gsize,ci1g(i1),ci2g(i1),ci3g(i1),msg(i1),mdg,cd1g,cd2g,cd3g,mscg);
[domb]=domsearch(rang1b(i1,:),dompoolb,gsize,ci1b(i1),ci2b(i1),ci3b(i1),msb(i1),mdb,cd1b,cd2b,cd3b,mscb);
dom=[domr,domg,domb];
[rz cz]=size(dom);
meanrar=mean(rang1r(i1,:));
meanrag=mean(rang1g(i1,:));
meanrab=mean(rang1b(i1,:));
meanra=cat(3,meanrar ,meanrag,meanrab);
for z=1:1:cz
dompolr(z,:)=dompoolr(dom(z),:);
end
for z=1:1:cz
dompolg(z,:)=dompoolg(dom(z),:);
end
for z=1:1:cz
dompolb(z,:)=dompoolb(dom(z),:);
end
dompol=cat(3,dompolr,dompolg,dompolb);
[isomer alphr meanrr dom1r errr]=affwerrqt(rang1r(i1,:),dompolr(1:cz,:),gsize);
[isomeg alphg meanrg dom1g errg]=affwerrqt(rang1g(i1,:),dompolg(1:cz,:),gsize);
[isomeb alphb meanrb dom1b errb]=affwerrqt(rang1b(i1,:),dompolb(1:cz,:),gsize);
cdom1r(w1)=dom(dom1r);
isome1r(w1)=isomer;
alph1r(w1)=alphr;
meanr1r(w1)=meanrar;
cdom1g(w1)=dom(dom1g);
isome1g(w1)=isomeg;
alph1g(w1)=alphg;
meanr1g(w1)=meanrag;
cdom1b(w1)=dom(dom1b);
isome1b(w1)=isomeb;
alph1b(w1)=alphb;
meanr1b(w1)=meanrab;
cdom1=cat(3,cdom1r,cdom1g,cdom1b);
isome1=cat(3,isome1r,isome1g,isome1b);
alph1=cat(3,alph1r,alph1g,alph1b);
meanr1=cat(3,meanr1r,meanr1g);
vqcode3r(c,:)=[isome1r(w1),alph1r(w1),meanr1r(w1),cdom1r(w1)];
vqcode3g(c,:)=[isome1g(w1),alph1g(w1),meanr1g(w1),cdom1g(w1)];
vqcode3b(c,:)=[isome1b(w1),alph1b(w1),meanr1b(w1),cdom1b(w1)];
c=c+1;
vqcode3=cat(3,vqcode3r,vqcode3g,vqcode3b);
end
w1=w1+1;
end
Any one please give me a solution for this problem .
3 commentaires
For using parfor loop, the task within the loop should be independent, that is the ith task does not depend on the (i-1)th task before.
There are several index variables, which I'm not sure whether they should appear in order. If they're ordered, you can't use parfor for this problem.
PRIYANGA
le 30 Jan 2013
Randy Souza
le 12 Fév 2013
I have restored the original text of this question.
PRIYANGA, this question has a clear subject and an accepted answer, so it may be valuable to someone else in the future. If you have a good reason why it should be removed from MATLAB Answers, please flag the question, explain why it should be deleted, and an administrator or high-reputation contributor will consider deleting the question. Please do not simply edit your question away.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Performance and Memory dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!