Problem in parallel computing (par for)
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Deepak Meena
2021-7-5
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
Thanks
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!