Problem in parallel computing (par for)

5 vues (au cours des 30 derniers jours)
Saurav Dutta
Saurav Dutta le 8 Avr 2020
iu_start=1;
iu_end=2;
ju_start=1;
ju_end=50;
Ki=0.05;
tic
for Kpp=iu_start:iu_start:iu_end
Kp=Kpp/1
for Kvv=ju_start:ju_start:ju_end
Kv=Kvv/10;
timespan=[0 24];
IC=eye(12,12);
initialconditions=[IC(:,1)',IC(:,2)',IC(:,3)',IC(:,4)',IC(:,5)',IC(:,6)',IC(:,7)',IC(:,8)',IC(:,9)',IC(:,10)',IC(:,11)',IC(:,12)'];
options=odeset('abstol',1e-9,'reltol',1e-9);
[t,z]=ode15s(@rRRPvvv,timespan,initialconditions);
a=z(end,:);
a1=a(:,1:12);
a2=a(:,13:24);
a3=a(:,25:36);
a4=a(:,37:48);
a5=a(:,49:60);
a6=a(:,61:72);
a7=a(:,73:84);
a8=a(:,85:96);
a9=a(:,97:108);
a10=a(:,109:120);
a11=a(:,121:132);
a12=a(:,133:144);
cc{Kpp,Kvv}=[a1',a2',a3',a4',a5',a6',a7',a8',a9',a10',a11',a12'];
egr{Kpp,Kvv}=eig(cc{Kpp,Kvv});
absegr{Kpp,Kvv}=abs(egr{Kpp,Kvv});
end
end
The above code works perfectly. Now, when I make the outer for loop par for and run it,it shows the error "Error using rRRPlen (line 20)
Error: The variable cc in a parfor cannot be classified.
See Parallel for Loops in MATLAB, "Overview".
Please help
  2 commentaires
Mohammad Sami
Mohammad Sami le 8 Avr 2020
Declare cc, egr and absegr before the parfor loop.
cc = cell(2,50);
Saurav Dutta
Saurav Dutta le 8 Avr 2020
The problem still remains with the same error message

Connectez-vous pour commenter.

Réponses (1)

Deepak Meena
Deepak Meena le 5 Juil 2021
Hi ,
I tried to reproduce the error , you mentioned the code works fine without the parfor command but in my case it is giving error
Unrecognized function or variable 'rRRPvvv'.
To reproduce the issue I removed the differetial equation part and I trimmed down the code to :
iu_start=1;
iu_end=2;
ju_start=1;
ju_end=50;
Ki=0.05;
cc = cell(2,50);
egr = cell(2,50);
absegr = cell(2,50);
tic
parfor Kpp=iu_start:iu_end
Kp=Kpp/1
for Kvv=ju_start:ju_start:ju_end
Kv=Kvv/10;
a = rand(200,200);
a1=a(:,1:12);
a2=a(:,13:24);
a3=a(:,25:36);
a4=a(:,37:48);
a5=a(:,49:60);
a6=a(:,61:72);
a7=a(:,73:84);
a8=a(:,85:96);
a9=a(:,97:108);
a10=a(:,109:120);
a11=a(:,121:132);
a12=a(:,133:144);
cc{Kpp,Kvv}=[a1',a2',a3',a4',a5',a6',a7',a8',a9',a10',a11',a12'];
egr{Kpp,Kvv}=cc{Kpp,Kvv};
absegr{Kpp,Kvv}=abs(egr{Kpp,Kvv});
end
end
toc
I followed the suggestion provided by the @Mohammad Sami and it didn't throw that error.
Thanks

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by