Undefined command/function
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 7 de Mayo de 2012
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
el 7 de Mayo de 2012
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.
Respuesta aceptada
Más respuestas (5)
Jan
el 7 de Mayo de 2012
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
el 7 de Mayo de 2012
0 votos
1 comentario
Jan
el 8 de Mayo de 2012
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
el 7 de Mayo de 2012
1 comentario
Walter Roberson
el 7 de Mayo de 2012
What does
which -all make_new_project
show?
ragna-b
el 8 de Mayo de 2012
ragna-b
el 8 de Mayo de 2012
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!