trouble to run a file directly from current directory

Hello..Every time,I open matlab,I get following type of error message and a warning in command window automatically:
Warning: Function C:\Users\Dell\Documents\MATLAB\sin.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.
& error message is:
??? Attempt to execute SCRIPT dir as a function: C:\Users\Dell\Documents\MATLAB\dir.m
Also same type of error message appears whenever I try to run a file directly from the current directory.
what should I do? Can anybody help me?

 Accepted Answer

You have been naming M-files with the same name as built-in functions. Now you see the reasons why this is not recommended. To fix the problem, clear MATLAB (type: clear all) then open the folder:
C:\Users\Dell\Documents\MATLAB
in Windows explorer. Right-click on the sin.m file and rename it to mysin. Then click on the dir.m file and rename it to mydir. From now on, do not name your files with the same name as a MATLAB built-in function.
To check if the name you want is already taken, do this (for example, check if there is already a file named repmat, then check if the file named waldo exists):
which repmat
which waldo
If you see this:
'waldo' not found.
then you could name a file waldo without this problem. But if you see other results, then that file already exists.

Categories

Tags

Asked:

on 25 Apr 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!