start matlab with relative path

조회 수: 2 (최근 30일)
Dario Vazquez
Dario Vazquez 2018년 2월 8일
댓글: Walter Roberson 2018년 2월 8일
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 :)

채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 8일
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
Walter Roberson
Walter Roberson 2018년 2월 8일
For example,
matlab -r "try;run('\\folder1\\folder2\\ducttape.m'); end; quit"

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Adding custom doc에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by