Saturday, January 21, 2012

Matlab filename.m run error

I've started learning and using MATLAB. Installed version 7.9.0 (R2009b). After learning few basics, moved to .m files. I created a file named 1.m and trying to run the file. But I couldn't. The error message is

" File C:\Users\RaviTeja\Documents\MATLAB\1.m is not found in the current directory or on the matlab path. "

It also offers some explanation i.e

" To run this file, you can either change the MATLAB current directory or add its directory to the MATLAB path "

Actually this error message and explanation, both are misleading in my case.

There are three things you need to check. They are :

  1. Change current directory to the file directory i.e to  C:\Users\RaviTeja\Documents\MATLAB\ in my case. If this is done, skip to step 3.
  2. Even by ignoring the above step, you can proceed. Goto file --> Set Path --> Add Folder --> select the folder in which your files are stored. This is preferable.
  3. File-names with .m as extension should start with a letter. This is the wrong step I did. So renaming my file 1.m to a.m solved my problem. Surely, this works for you .

PS : I'll start posting the errors which I've encountered daily from now on. Keep visiting

If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

No comments:
Write comments