Filter löschen
Filter löschen

I can't delete the file obtained with matlab

29 Ansichten (letzte 30 Tage)
Luca Re
Luca Re am 21 Jul. 2024 um 14:18
Bearbeitet: Walter Roberson am 21 Jul. 2024 um 18:41
.....
writecell(bu,hhh,'Delimiter',' ');
when I kill writecell process (using ctrl+c) in matlab i receive this error and if i try to delete file
i receive this error:
The operation could not be completed because the file is open in matlab R2024a

Akzeptierte Antwort

dpb
dpb am 21 Jul. 2024 um 15:02
Verschoben: dpb am 21 Jul. 2024 um 15:02
You'll have to exit and restart MATLAB, then...
I've never had MATLAB keep the file handle open; Excel if using ActiveX and crash, yes, but not MATLAB.
Somehow the error handler/cleanup function isn't managing to close the open file and let the OS know. That is worthy of a bug report, but it is probably not reliably reproducible.
But, Ctrl-C while writing a file is risky behavior although ideally it should be able to be handled...
  3 Kommentare
Luca Re
Luca Re am 21 Jul. 2024 um 15:24
I can create a button with "Break" to press to avoid the ctrl+c but how should I code it?
dpb
dpb am 21 Jul. 2024 um 16:21
There is no provided facility for that; you would have to stuff the Ctrl-C into the keyboard buffer and drawnow to update callbacks (and not sure that would work). Such things should be avoided.
The only clean way to do something of that sort would be to not dispatch the writecell call with the entire file but in a loop and check for user cancellation at the end of each pass through the loop. This would obviously add even more overhead and have a latency period (MsgBox("Please Standby")) until the current call completes and can check the flag to terminate.
What and how large a file are you writing such that it is wanted to cancel the operation? If the user asked to write the file, it would seem a fairly rare event to then subsequently want to cancel?
I think it may be worth a support request to Mathworks about the open file handle from the command line to see if they think that is expected behavior or not despite the poor practice from user. I would think the registered cleanup functions should be able to deal with it cleanly, but it's worth asking about. As said, I've not seen the symptom, but I've not done the exercise that often and don't have that release of MATLAB installed.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Report Generator 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!

Translated by