Error using delete after closing file
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Scope Variables and Generate Names finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!