Error in buit in function
12 views (last 30 days)
Show older comments
Mo BO
on 10 May 2016
Commented: Walter Roberson
on 10 May 2016
i get error in built in function and i can't find out why and while trying to figure it out, i looked it up in the help and took the same example and then executed it in the command windows after trying the code i always get the same error ,but if cleared the work space and tried the example again before trying the code it works well it looks like the code make some thing wrong with the matlab *
3 Comments
Accepted Answer
Walter Roberson
on 10 May 2016
When you created double.m in a local directory, and put the local directory on the path, that affected most calls to double(). MATLAB mostly finds appropriate routines by name: it usually starts at the beginning of the MATLAB path and looks for a double() in each directory until it finds one. It does not matter that the first routine you invoke does not call double(): that routine invokes another routine that does call double(), and the double.m that you put on the path now overrides the built-in double() routine.
You should not name your .m files the same as any Mathworks-provided routine unless you want your routine to be called instead of the Mathworks provided routine.
4 Comments
Walter Roberson
on 10 May 2016
Your function might be changing the MATLAB path.
To see if any particular name is in use for a function, use
which TheNameToCheck
for example
which image
which doublefactorial
The second of those turns out not to be used (but there is a MuPAD double factorial function named fact2)
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!