Error using delete after closing file
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Scope Variables and Generate Names in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!