Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01245ec

Browse files
committed
Respect current directory when starting MATLAB on Windows
Also suppress verbose startup output by suffixing commands with semicolon. Current directory was not respected on Windows when -automation flag is used, as previously reported below: http://www.mathworks.com/matlabcentral/answers/58372-can-t-change-startup-directory-when-calling-matlab-with-automation-from-command-line
1 parent ab0cdb5 commit 01245ec

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pymatbridge/pymatbridge.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,11 @@ def _preamble_code(self):
176176
# suppress warnings while loading the path, in the case of
177177
# overshadowing a built-in function on a newer version of
178178
# Matlab (e.g. isrow)
179-
return ["old_warning_state = warning('off','all')",
180-
"addpath(genpath('%s'))" % MATLAB_FOLDER,
181-
"warning(old_warning_state)",
182-
"clear old_warning_state"]
179+
return ["old_warning_state = warning('off','all');",
180+
"addpath(genpath('%s'));" % MATLAB_FOLDER,
181+
"warning(old_warning_state);",
182+
"clear('old_warning_state');",
183+
"cd('%s');" % os.getcwd()]
183184

184185
def _execute_flag(self): # pragma: no cover
185186
raise NotImplemented

0 commit comments

Comments
 (0)