function error- undefined variable

when i attempt to use a function an error occurs saying 'undefined function or variable' or it says there is an error in the script but there are none according to the side bar. its happening to every function i have - even the ones that were working previously.. HELP?!?

 채택된 답변

Walter Roberson
Walter Roberson 2011년 6월 11일

0 개 추천

Please copy and paste the error here.
It could be that you accidentally added your own routine with the same name as one of the built-in routines.

댓글 수: 5

Corinne
Corinne 2011년 6월 11일
do you have any idea how to fix this?
thanks
Walter Roberson
Walter Roberson 2011년 6월 11일
You need to copy the exact error here so we can figure out which routine is involved. After that, you would use the "which" command on that function to determine where you accidentally wrote the file that is overriding the MATLAB version.
Corinne
Corinne 2011년 6월 12일
it was saying undefined function or variable but now its:
??? Input argument "a" is undefined.
Error in ==> get_positives at 23
for element = a
but this function was working before...
i was reading the help document stuff and it said if the undefined error came up to change 'set path' to default. ive done that but still no luck.
Walter Roberson
Walter Roberson 2011년 6월 12일
What statement in your code defines "a" ?
It is possible that you have a function instead of a script, and that you need to invoke the function from the command line, passing in the appropriate arguments. Look at the first non-comment line of get_positives.m and see if it starts with "function": if it does then at the command line you need to type something like
get_positives([-5,3,8,pi,-2,inf])
Corinne
Corinne 2011년 6월 13일
all is good thanks for your help.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by