I am using the Matlab parallel toolbox to do parallel computing. I've doubled check the variable definition of the code, and it follows the requirements of parfor command. However, Matlab still told me that "Transparency Violation Error," could you help me figure out this issue?
Here is the source code. Thank you so much.
load Wind80.mat
Wspeed_80 = Wind80;
TotalLoc = 4000;
Nloc = 5; % no of loc of each run
maxrun = ceil(TotalLoc/Nloc);
StrInfo.Pstr = 1;
StrInfo.Tstr = 0:4:72;
tic
parfor run = 1:maxrun
WT1 = [];
WT2 = [];
[WT1, WT2] = CompWTGenFun(run, Nloc, TotalLoc, StrInfo);
filenm = ['ResultPara' num2str(StrInfo.Pstr) 'Run' num2str(run) '.mat' ];
save(filenm, 'WT1', 'WT2', '-mat');
clear WT1 WT2
end
toc
WT1andWT2to empty matrices has no purpose, andclear WT1 WT2is a pessimization (clearwill typically slow down your code). - Cris Luengofilenmwill be different for each loop iteration. Try generating the file names outside the loop, then in the loopsave(filenm{run},...). - Cris Luengo