I am trying to run a Matlab script from Windows command prompt but I can’t execute it sometimes. The script runs fine when manually launched. Matlab version is 2011a and Windows is Server 2003 SP2. Details:
Script mytask.m is located inside say E:\Production\Project. This is SAVED on Matlab’s path.
When I place mytask.m inside bin folder, it executes fine by the command:
`C:\Program Files\MATLAB\R2011a\bin>matlab -r mytask`
If you delete it and try to access it at its original location, the script doesn’t run although Matlab editor window is launched:
`C:\Program Files\MATLAB\R2011a\bin>matlab -r "E:\Production\Project\mytask"
Any suggestions please? Thanks.
The syntax for
matlab -risIn other words, you need to provide some executable commands as the statement. For example:
However, it seems that matlab does not load the customized paths in this way. If you have some customized paths, you probably have to define them in
startup.mand place thisstartup.min the directory where you invoke matlab.I didn’t check myself, but if you define
E:\Production\Project\as the path instartup.m, you probably can runmatlab -r mytaskwithout problem, asmytaskwill be recognized as a user function/script.A simple example of
startup.m