Different behaviour while running Matlab script from DOS window
Mostrar comentarios más antiguos
Hi,
I have a problem starting Matlab from DOS window for different versions of Matlab.
When I call Matlab 2010bSp1 (32 bit) from DOS window to run a script, I do not see any problem.
C:\ProgramFiles\matlab\r2010bsp1\bin\matlab.exe -r "add.m"
When I call Matlab 2014a (64 bit) from DOS window to run the same script, I see a problem
C:\ProgramFiles\matlab\r2014a\bin\matlab.exe -r "add.m"
The MATLAB command window shows Undefined variable "add" or function "add.m".
Note that the path of "add.m" is not added to search path of Matlab in either case.
Can anyone please let me know why MATLAB r2014a version is not able to identify "add.m"?
Any help is highly appreciated.
1 comentario
Walter Roberson
el 18 de Sept. de 2016
Note: there is an R2010bSp2 that you are entitled to if you have R2010bSp1 .
Respuesta aceptada
Más respuestas (1)
Jan
el 16 de Sept. de 2016
0 votos
If add.m is not added to the Matlab path, it should not work in R2010. Why does this Matlab version find the function? Is it in the userpath or in the current path?
If you want Matlab 2014a to find the function, adding it to the Matlab path is obligatory.
4 comentarios
Nagaraj
el 17 de Sept. de 2016
Jan
el 17 de Sept. de 2016
The workaround is clear: Add the folder to the path, e.g. by addpath or add it in the calling sequence in the command line.
By the way: The command shoulöd not be called "add.m", but "add", because ".m" does not belong to the Matlab command.
Nagaraj Ramachandra
el 19 de Sept. de 2016
The issue mentioned by me is regarding running M-script from Windows Command Prompt.
In my case, I cannot add the script folder to MATLAB's search path. I have lots of M-scripts(which are in different locations) which I want to run from Windows command prompt.
I have created a service request and Mathworks engineer is looking into the issue.
Jan
el 20 de Sept. de 2016
You can add the path easily when Matlab is called from the command line:
matlab -r "addpath('C:\Your\Path'); add"
or if add.m is a script and not a function file:
matlab -r "run('C:\Your\Path\add')"
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!