MATLAB error when running the program "try.m"

Go To StackoverFlow.com

3

After creating a MATLAB (version 2010a) file in the editor, I am getting the below mentioned error:

"MATLAB cannot run this file because \toolbox\matlab\lang\try.m shadows it in MATLAB path"

Also with this I get an option to "change folder", "add the path". Even after clicking and working around with this option I keep getting the same message.

I looked up in the matlab manual and tried to change the path. Also I checked my path variable, the place where I am storing my matlab files is already there in the path variable. Please help correcting the error. The name of my file is try.m The code inside 'try.m' is just:

 clear all;
2012-04-04 17:46
by Jannat Arora


8

TRY is a reserved word in MATLAB, so you shouldn't use it for your filename. Rename "try.m" to something else and you should be fine. You can do this using the "Save As" from the Editor menu and typing a different name.

2012-04-04 18:08
by Matthew Simoneau
@Thanks a ton for helpin - Jannat Arora 2012-04-04 18:11
These problems are irritating and languages usually don't give particularly clear error messages. I got stumped for days when I decided to call my first C program time, and any system I ran it on gave very unexpected outputs - Bill Cheatham 2012-04-04 18:16


0

Is your file in the file editor also named lang.m? Because Matlab sometimes cannot resolve scope differences between m-files in the current directory and m-files that represent built-in functions. It does not appear to be telling you that your file is not in the path; rather it seems to be saying it cannot distinguish your file from \toolbox\matlab\lang.

Can you provide more details about what your file is, such as posting the code and including the working directory name?

2012-04-04 17:50
by ely
thanks for helping. The code is simple e.g. even if I am writing "clear all"...i m getting stuck...also the name of my file is "try.m - Jannat Arora 2012-04-04 17:53
According to this link they suggest to close and re-open the m-file and try again. Have you done this? Have you tried closing and restarting Matlab as well - ely 2012-04-04 18:11
Ads