Change Directory (cd)
18 views (last 30 days)
Show older comments
Hi, I need to change the current directory of Matlab in a m file. I want to know if its possible to use a variable to change the directory
Here's my problem:
I have a variable containing a name of folder. (var = Nameoffolder). Then, I run a .exe in matlab and it writes results in some .txt files in a folder with the same name that my variable After, I want Matlab to post-process my data. So I want change the current directory to ..\Nameoffolder
How can I do this ?
Thx for the help !!
0 Comments
Answers (1)
Ross
on 23 Jan 2012
I'm interpreting your question as: I have a variable of class 'char', ie a variable that defines the directory you want to change to. cd can be called two ways. The first requires the actual text, ie
cd ~/myfilepath
However, you can also use:
filepathString = '~/myfilepath';
cd(filepathString);
Does that answer your question?
0 Comments
See Also
Categories
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!