Windows is notorious in general for having issues with manipulating a file in one program that was used in another program, including in Python. Matlab seems to suffer from this problem as well, including when manipulating:
- HDF5 file that was previously accessed in Matlab
- .m files and folders that were previously edited in Matlab
The workaround is to completely close all Matlab sessions, then generally you can move or delete the files that Matlab previously accessed. Then reopen Matlab.