Filter löschen
Filter löschen

current directory on startup

4 Ansichten (letzte 30 Tage)
Adam
Adam am 8 Mai 2012
If you have a Matlab exe that needs to read a txt file located in the same directory as the exe but you don't have aprori knowledge of the directory name. And when you start the Matlab exe in C:\blah\blah\whatever directory
it looks in win\system32 for the text file.
Is there some generic default $CURRENT you can use in the Matlab code to cd($CURRENT) to force the exe to always look in the directory that it is located in to find the file?

Antworten (5)

Sean de Wolski
Sean de Wolski am 8 Mai 2012
You could always have a startup.m that cd() to the folder you want at startup.
doc startup
doc cd
Not sure is this is what you're looking for.

Jason Ross
Jason Ross am 8 Mai 2012
Could use you "matlabroot" to determine the directory of the .exe and then fullfile and cd to get where you wanted to go? There's an example on the matlabroot doc page:

Adam
Adam am 8 Mai 2012
Thanks for the reply...
It is close. If I knew the directory the exe and txt were copied into. However all I know is that they will always be in the same directory. So I need the exe to look in its location for the file.

Adam
Adam am 8 Mai 2012
I'll take a look at the link and see...

Jason Ross
Jason Ross am 8 Mai 2012
If you are using a deployed application, you might also find value in the ctfroot:

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by