Windows 7, Matlab 2007b.
I want to call Matlab to run a script from a windows 7 .bat file. I'm using the command:
matlab -automation -r myScript
The problem is that the script needs to access some files in (or relative to) the directory where the bat file is located. In theory this shouldn't be a problem since the startup directory should be the same directory as the bat file, from Matlab help:
"When you do not specify the -sd option, the startup directory is the directory from which you ran matlab"
But in practice the startup directory is the Matlab root directory: C:\Program Files\MATLAB\R2007b
I tried also explicitly setting the startup directory using:
matlab -automation -sd "%CD%" -r myScript
but the startup directory is still Matlab root.
The problem only happens with the -automation flag, if I leave that out then it works fine - but if I leave that out then Matlab takes much longer to start and it slows down my whole process.