Scatter plot in parfor loop
Show older comments
Hi everyone, I'm having some problems for creating a scatter plot. I'm using a parfor loop in order to address an optimization problem for sizing a transformer. In each iteration a suitable function is solved with the aim to find the geometrical parameters of the transformer. Hovewer two of the data that I have to evaluate at each iteration are the efficency and power density. After evaluating them thanks to the function I have written, I need to create an unique scatter plot 'efficiency' versus 'power density' that reports all the sizing that have been realized. Below I attached the matlab code I have implemented. Thanks for your supporting.
Variables r,i, frontal section and so on are free variables wich varing in a specific range of values
j=1;
parfor r= 1:3
for i = [100 200 300]
for frontal_section = 36
for layer = 2
for turn_per_layer = 5:10
for x = 0.22
for a = 0.66
for d_s_1 = 0.05
for d_s_2 = 0.05
[diso_min,dins_int1,dins_1,dt_1,Irms1,Irms1_1,nsh_1,nsv_1,Ns1,hb_1,wb_1,hw,W1,dt_2,dins_int2,Irms2,Irms2_1,nsh_2,nsv_2,Ns2,Nl_2,m2,hb_2,wb_2,dins_2,W2,dc_1,dc_2,MLT1,diso,MLT2,MLTiso,Ac,B,H,G,Vc,V_cl,V_sl_y,Lbox,Wbox,Hbox,Vbox,power_density,Pc_s,Pc,P_cl,P_sl_y,Rth_cl,Rth_LV_cl,Rth_iso,Rth_pol_LV,Rth_pol_HVr,Rth_pol_HVz,Rth_hs_LV,Rth_hs_HV,Rth_hs_sl_y,Rth_hs_amb,Aconv_HV,Arad_HV,Aconv_sl,Arad_sl,Lconv_HV,Lconv_sl,Pw1_r,Pw2_r,Pwt_r,Ploss,T_sl_r,T_HV_r,T_LV_r,T_cl_r,T_sl_y_r,T_B_HS_r,efficiency] = Procedure_with_litz_wire_strand_imposed_by_user_prova_parfor(Pout,Vdc_1,Vdc_2,n_cells,s_c,Vdc_1_cell,Vdc_2_cell,n,Viso,fsw,T,Ta,Tmax,d,phi,Lk,core_material,Bsat,kc,alpha,beta,Kc,rho_core,kcore,Ec,Tmax_core,Eins,Eins_b,Tconductivity_b,Epol,r,i,s,frontal_section,layer,turn_per_layer,x,a,d_s_1,d_s_2);
if (T_HV_r <= Tmax)&&(T_LV_r <= Tmax)&&(T_sl_r <= Tmax_core)&&(diso>= (diso_min))
Iteration = j;
c = T_LV_r - Ta;
po = scatter(power_density,efficiency,[],c, 'filled');
row = dataTipTextRow('Iteration',Iteration);
po.DataTipTemplate.DataTipRows(end+1) = row;
colorbar
hold on
end
end
end
end
end
end
end
end
end
end
2 Comments
Matt J
on 10 Jan 2022
Yes, but what is your question? What problem are you encountering?
Stefano Menicanti
on 10 Jan 2022
Answers (1)
Matt J
on 10 Jan 2022
0 votes
Parfor workers do not have display capability, but you can gather the data in the loop and plot it after the loop.
2 Comments
Stefano Menicanti
on 10 Jan 2022
Here is a simplified example:
parfor r=1:3 %generate data
X{r}=rand(1,10);
Y{r}=rand(1,10);
end
for r=1:3 %%plot data
figure;
scatter(X{r},Y{r})
end
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!