Executing matlab script from static directory with current path as input in linux (as alias)

Hello everybody.
I am currently trying to execute a matlab script from a static directory with inputs from dynamic ones as an alias. Basically I manually change the directory to where the files (inputs) are and then execute a matlab script with an alias. This alias should include the current path as well as the execution of the script from a static directory.
My solution so far is:
matlab -nojvm -nodisplay -nosplash -batch path=pwd;run('/pathToScript/script');
When using this solution the "error message" always is zsh:unknown file attribute. Im relatively new to linux.
When using the above solution in two separate steps:
matlab -nojvm -nodisplay -nosplash path=pwd;
%in matlab environment
run('/pathToScript/script');
it works just fine. So basically using the alias to do both executions is just for reducing time.
Thanks

 Respuesta aceptada

matlab -nojvm -nodisplay -nosplash -batch "path=pwd;run('/pathToScript/script');"
However I would suggest it would be safer to
matlab -nojvm -nodisplay -nosplash -batch "addpath(pwd);run('/pathToScript/script');"

2 comentarios

Thank you very much. This solves the problem of the execution of both commands. Do you know by any chance how to implement this in an alias? Using:
alias knock = 'matlab -nojvm -nodisplay -nosplash -batch "addpath(pwd);run('/pathToScript/script');"'
results in "Error: Invalid use of operator" for the "/" in /pathToScript. Somehow the " ' " is ended after run(' .
Thanks
alias knock="matlab -nojvm -nodisplay -nosplash -batch \"addpath(pwd);run(\\\"/pathToScript/script\\\");\""
It was tricky to get everything escaped just the right way.
At one level you are executing a shell command to create an alias. But the alias that is created has to be something that can be executed again, so you end up having to double-escape when building the alias.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Etiquetas

Preguntada:

el 6 de Mayo de 2020

Comentada:

el 6 de Mayo de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by