Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Problem running and editing Matlab scripts

Asked by Michael on 21 Mar 2014
Latest activity Answered by Michael on 22 May 2014

Recently I began having a problem with Matlab where I'm unable to open and edit or run a script without getting an error message from Matlab editor saying,

"Error writing [File I'm trying to run/save] [Location of file on disk] (The process cannot access the file because it is being used by another process)".

This only happens after I've opened any saved file and edited it. After editing I cannot run or save the file without getting this error message. I can however start a new file and am able to both save it and run it multiple times without any problems. As soon as I close and reopen it again, I get the error message.

Is there something I accidentally changed? I have checked all the permissions in Windows and I should have no problem reading or writing files.

Matlab R2013a, Windows 7 Enterprise

3 Comments

Joseph Cheng on 21 Mar 2014

Does fully closing down Matlab and reopening grant you access to the file again? I know it's stupid and you've already checked permissions in windows but since it is Enterprise have you checked the permissions of the files in question not just folder or user access?

Michael on 22 Mar 2014

I'm not having problems accessing the file or editing it, the problem occurs when I try to save or run the script after I've reopened it in the editor. Neither closing down Matlab nor restarting my computer fixes the problem. I checked and all the files have full permissions. I've also run Matlab as an administrator and this has no effect.

Star Strider on 22 Mar 2014

The only diagnostic I can think of is to open Task Manager to see if any other application could be open that might access ‘.m’ files. Does any other application associate with ‘.m’ files?

It may be time to ask Support for help.

Michael

Products

No products are associated with this question.

2 Answers

Answer by Image Analyst on 22 Mar 2014

What is the folder of the file? Is it under c:\Program Files? If so, you're out of luck. If not, what is the folder? There are other folders that you're supposed to be able to write into but sometimes can't (like c:\ProgramData) and others that you think you should be able to but can't (like c:\users).

Close MATLAB and type Ctrl-Shift-Esc. Click the process tab. Do you still see an instance of MATLAB running?

If you don't see it, then you need to download "unlocker" http://download.cnet.com/Unlocker/3000-2248_4-10493998.html. Install that and when you get a file collision it will tell you what's got the file locked and give you the opportunity to pry it's grip off your file. Then once you see what other process has locked your file then maybe you can do something to avoid it in the future.

6 Comments

Image Analyst on 23 Mar 2014

Can you leave unlocker up and running while you step through your code to see when (what lines of code) place the lock on it?

Michael on 23 Mar 2014

It's not the code it's self causing the problem as it happens with any file I've re-opened, edited and attempted to save. I've tried creating a new file with no code and saving it, but as soon as I close and reopen, edit and attempt to save it again, I get the error message. All instances of Matlab shown on Unlocker happen at the same time when I open up any file. Could it be possible that Matlab is somehow preventing itself from saving files?

Image Analyst on 24 Mar 2014

I've run out of ideas. You might have to call the Mathworks. They can set up a Webex session with you, and drive your computer, and solve it for you.

Image Analyst
Answer by Michael on 22 May 2014

I contacted the Mathworks service department and they advised me to upgrade to R2014a, which fixed the problem.

0 Comments

Michael

Contact us