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.
ragna-b
2012 年 5 月 7 日
1 件のコメント
Walter Roberson
2012 年 5 月 7 日
What does
which -all make_new_project
show?
ragna-b
2012 年 5 月 8 日
ragna-b
2012 年 5 月 8 日
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!