Error: -16 Access Denied on xPc Target

2 Ansichten (letzte 30 Tage)
Nathan
Nathan am 19 Aug. 2014
Kommentiert: Nathan am 20 Aug. 2014
I am trying to create a file to run a batch of tests saving the resulting .DAT file from the File Scope each time. What I have found is that the .DAT file is created on the first run but subsequent runs aren't able to access it to overwrite the data involved meaning i get the data from the original test saved multiple times. Have included my code below, I believe the problem lies with the SIHS.dat file being opened but not closed.
widths=[0.1 0.3 0.5 0.7];
frequencys=[10 50 200 30];
rtwbuild('SIHSBatch');
fsys=xpctarget.fs;
for n=1:4
num=num2str(n);
exp=strcat('Qloss',num);
setparam(tg,0,widths(n));
setparam(tg,1,frequencys(n));
tg.start
while strcmp(tg.Status,'running')
pause(0.05)
end
h=fsys.fopen('SIHS.DAT');
data=fsys.fread(h);
fclose('all');
eval([exp '=readxpcfile(data)']);
filename=strcat('Qloss',num2str(n),'.mat');
save(filename,exp);
end

Antworten (1)

Rajiv Ghosh-Roy
Rajiv Ghosh-Roy am 20 Aug. 2014
You are correct in guessing that the file is not closed properly. You need to change the fclose call in
h=fsys.fopen('SIHS.DAT');
data=fsys.fread(h);
fclose('all');
to
fsys.fclose(h)
  1 Kommentar
Nathan
Nathan am 20 Aug. 2014
Rajiv, thank you for your answer, I have tried that and it produced an error. However I found that when i moved:
fsys=xpctarget.fs;
inside the loop the fclose function worked and thus the other code did as well.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by