I can't delete the file obtained with matlab
18 次查看(过去 30 天)
显示 更早的评论
.....
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
0 个评论
采纳的回答
dpb
2024-7-21
移动:dpb
2024-7-21
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 个评论
dpb
2024-7-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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!