MATLAB: Do I receive a “Permission denied” error when I try to save the Simulink model files in Simulink 7.0 (R2007b)

bakdeniedmdlpermissionsimulink

When I open a Simulink model file, make some changes and then immediately try to save the file, I receive the following error:
Error renaming mymodel.mdl to mymodel.bak. Permission denied”.
However, if I wait for about 30 seconds and try to save the file again, the error does not occur. This happens whether or not I have pre-save and post-save callback defined for the models.

Best Answer

If the option to show M and MDL-file descriptions is turned on in the current directory section of the user’s preferences, the MATLAB desktop will temporarily lock the files in the current directory to obtain these file descriptions. If the save event for the model file occurs at the same time, then the user can receive the permission denied error.
To workaround this issue, please try unchecking the option 'Show M and MDL file Descriptions' in MATLAB File menu -> Preferences -> Current Directory.