Transparency violation error. 'save' in 'parfor' loop
4 views (last 30 days)
Show older comments
Giridhar sai pavan kumar Konduru
on 12 May 2021
Answered: Mohammad Sami
on 12 May 2021
I am new to coding,
Here's the complete code:
Dset = 'visit3'; % visit3
Mpath = 'E:\OneDrive - IITRAM'; %dataset path
Lpath = 'E:\datasetttt\numom2b\polysomnography';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sp1 = 'MAT files';
op1 = 'edfs'; %edfs
op2 = 'annotations-events-profusion'; %xml
Ldir = struct2cell(dir([Lpath,'\',op1,'\',Dset]));
Ldir = Ldir(1,3:end)';
sp2 = strcat(Mpath,'\',sp1,'\',Dset);
if isfolder(sp2) ==0
mkdir(sp2)
end
parfor i = 1:1903 %size(Ldir,1)
CSname = char(Ldir(i,1));
[hdr, record] = edfread(CSname); % Edf2mat
CSname = CSname(1:end-4);
y = xml2struct([CSname,'-profusion.xml'],0);
save([sp2,'\',CSname,'_rec'],'record')
save([sp2,'\',CSname,'_info'],'hdr','y')
clc
disp(i)
toc
end
I know this error comes cuz of the 'save' in 'parfor' loop
people have suggested that we have to define the save as a function
But i am having a hard time figuring it out
I'd be glad if someone helps
thank you.
0 Comments
Accepted Answer
Mohammad Sami
on 12 May 2021
How about you define two save functions
function mysave1(sp2,CSname,record)
save([sp2,'\',CSname,'_rec'],'record');
end
function mysave2(sp2,CSname,hdr,y)
save([sp2,'\',CSname,'_info'],'hdr','y')
end
Then just call these in your parfor loop.
0 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements 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!