Change Directory (cd)

조회 수: 17 (최근 30일)
Marc-André Lemieux
Marc-André Lemieux 2012년 1월 23일
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 !!

답변 (1개)

Ross
Ross 2012년 1월 23일
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?

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by