Change working directory to where the mlx file is saved

8 views (last 30 days)
I have an mlx file which is run from different computers and I would like to automatically change the working directory to the directory in which the file is stored in (maybe with pwd??).
That is, I have identical copies of the mlx file which are run either from computer 1 or computer 2 (there are actually a lot more users involved, this is just an example):
In computer 1, the mlx files is stored in say this folder:
In computer 2, it is here:
Is it possible to run a command that identifies the folder that the mlx file is stored in, and then CD into that folder?

Answers (1)

Yongjian Feng
Yongjian Feng on 29 Nov 2021
If that folder is in the matlab's path, you can
which your_mlx_file.mlx
Metin Akyol
Metin Akyol on 29 Nov 2021
Excellent!!! Thank you so much Walter and Yongjian!!!

Sign in to comment.


Find more on File Operations in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by