Error using delete after closing file
显示 更早的评论
Hi
I have a function that closes either two files or a file and a serial port obj. But after closing them and calling delete I get an error message (Invalid or deleted object.). I'm not sure if I'm doing something wrong here. I thought you were supposed to call delete after closing a file obj? Fclose worked fine. I checked its error code, and its closing my files.
This is my code:
myfunc(x, etc)
fclose(x);
delete(x);
clear x;
I tried ishandle on it first, and got an error there too. It didn't seem to recognise x as a fileid. I tried nesting the function so i didn't have to pass any vars in, and that didn't make a difference. I also tried removing delete and calling it from the calling function, and still got an error.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Scope Variables and Generate Names 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!