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

CS Researcher
CS Researcher 2016년 5월 10일
It works fine on my system. You have not made any function called double, right?
Walter Roberson
Walter Roberson 2016년 5월 10일
Yup, clearly they have created double.m and put it on their path.
Mo BO
Mo BO 2016년 5월 10일
yes i have,but how is that effecting the built in function.I did't even call it or use it in by code

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 10일

1 개 추천

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

Mo BO
Mo BO 2016년 5월 10일
and that routine you mentioned is impeded in linspace,but not in all built in function so this error doesn't appear in all of my code ? did i get it right ?
Mo BO
Mo BO 2016년 5월 10일
ok,but why when i clear work space this problem is eliminated if i directly used the built in function in the command window and appear again in if tried it also in the command window but after executing the code ? and how i can know the names that matlab already use to avoid it
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)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2016년 5월 10일

댓글:

2016년 5월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by