MATLAB: How to close Excel-file after writetable()

close excelexcelshutdown excel

I want to use writetable() for an Excel-file in a for-loop. But at the second loop it stops with an error, because the first file is still open and there is no permission. Before I'd open a new folder for the new excel-file, but it doesn't work in this way now, because the file is still open.

Best Answer

I got this from the Mathworks directly:
You can use the following SYSTEM command via MATLAB to kill the process:
>> system('taskkill /F /IM EXCEL.EXE');