start matlab with relative path

1 vue (au cours des 30 derniers jours)
Dario Vazquez
Dario Vazquez le 8 Fév 2018
Commenté : Walter Roberson le 8 Fév 2018
Hello,
Im using matlab for automated test of my firmware, what I do is open matlab, set the current folder to the firmware folder and run matlab script, matlab script will get data from source code and test the circuit automatically, i want to automate a little further and add this to my make file.
Im using cygwin and I can call Matlab by just sending the command 'matlab', what i want to do is be able to send something like this:
matlab '\folder1\folder2\' ducttape
please note that the address is relative, because when i call matlab from cygwin automatically the current forlder is set to the one of the project, I cant change the address to 'folder2' because the make file has to be run from the project folder.
'ducttape' is the scripts name.
e.g: cygwin is set to open in: 'C:\project\' so i can run make file by just calling make, and the data required by matlab file is on 'C:\project\folder1\folder2\', I dont want to hardwire the data address on the script because i may program diferent settins in 'C:\project\folder1\folder3' and want to be able to change between setups and test
Thank you :)

Réponse acceptée

Walter Roberson
Walter Roberson le 8 Fév 2018
You can use run() for scripts, providing a path to the script. run() works by doing a cd to the appropriate folder (and cd()'s back upon exit from the script.)
  1 commentaire
Walter Roberson
Walter Roberson le 8 Fév 2018
For example,
matlab -r "try;run('\\folder1\\folder2\\ducttape.m'); end; quit"

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Adding custom doc dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by