Transparency violation error. 'save' in 'parfor' loop
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Giridhar sai pavan kumar Konduru
am 12 Mai 2021
Beantwortet: Mohammad Sami
am 12 Mai 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 Kommentare
Akzeptierte Antwort
Mohammad Sami
am 12 Mai 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!