Undefined command/function
이전 댓글 표시
Hello,
if have a problem to start/ run my selfwritten .m-files. First of all, I added the path where the m.-files are saved by 'Set path'. They are there in the list. I can also open the files by 'open example.m'. But if they are called in another m-file, I always receive:
'??? Undefined command/function example.m'
If I want to run the files via commandline I receive:
??? Undefined function or variable 'example.m'
as an error message.
Thanks for your help
댓글 수: 2
Walter Roberson
2012년 5월 7일
You should never include the '.m' in invoking a function or script. The exception to that is that if you use run() for a script, the .m can be included in the path name.
Jan
2012년 5월 7일
Please include a copy of the failing command in postings in this forum. It is a rare case, that the cause of an error can be guessed only based on the error message.
채택된 답변
추가 답변 (5개)
Jan
2012년 5월 7일
Omit the ".m" on the name of the function.
If the file is called "example.m" and starts with a function definition like e.g.:
function [out1, out2] = example(in1, in2)
...
then you have to call it like:
[a, b] = example(23, 17)
Such basic details are explained in the Getting Stared chapters of the documentation. It is recommended to take the time to read them, because they are fundamental for using such a high-power environment like Matlab.
ragna-b
2012년 5월 7일
0 개 추천
댓글 수: 1
Jan
2012년 5월 8일
Then it would have been a good idea to explain such details in the original post already. It wastes the time of yourself and of the contributors in this forum, if the details have to be guessed.
The error message '??? Undefined command/function example.m' cannot appear if you try to call "example()". Please post an exact copy of the error message in the future to increase the chance to get helpful answers.
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!