-
Notifications
You must be signed in to change notification settings - Fork 16
Tips and Tricks
If you'd like to call the smiler executable from a python script, you could do something like:
import subprocess
command = ["/path/to/your/smiler/executable", "run", "-e", "your_experiment.yaml"]
rc = subprocess.call(command)
You can do this with any smiler command. The rc value will be 0 on success, >0 on failure.
Here is some advice for installation and use for those unfamiliar with MATLAB in Linux, and the MATLAB.engine which is used to call MATLAB from python.
Contribution by Brian Wijeratne
- create a symbolic link to open MATLAB via command 'matlab' from any terminal
- my installation directory for MATLAB R2018b was: '/usr/local/MATLAB/R2018b'
- add MATLAB bin folder containing executable script to PATH, choose one of the following:
++
export PATH="/usr/local/MATLAB/R2018b/bin:$PATH"
restart terminal ORsource ~/.bashrc
++sudo gedit ~/.bashrc
(append)export PATH="/usr/local/MATLAB/R2018b/bin:$PATH"
restart terminal ORsource ~/.bashrc
- open MATLAB via terminal command 'matlab'
https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html
This may fail (permission problems, but then using sudo fails to properly install it too):
cd "matlabroot/extern/engines/python"
python setup.py install
This worked for me (Ubuntu 16.04 LTS, Python 2.7, 3.5, 3.6, Anaconda 4.3): https://stackoverflow.com/questions/45016671/import-error-no-module-named-matlab-engine
cd "matlabroot\extern\engines\python"
python setup.py build --build-base=$(mktemp -d) install
Test matlab.engine via commands (output: True): https://www.youtube.com/watch?v=yhnB7zWgi_Q
import matlab.engine
eng = matlab.engine.start_matlab()
tf = eng.isprime(37)
print(tf)