issue with using a variable for path name

조회 수: 3 (최근 30일)
sri satya ravi
sri satya ravi 2022년 4월 7일
댓글: sri satya ravi 2022년 4월 8일
I tried to save my path address to a variable and use the variable as CD funtion but i am getting an error.
Path = ('H:\dcx_cpe\CRANE\Truck Data');
cd('Path');
I am getting the below error.
Cannot CD to H:\dcx_cpe\CRANE\Truck Data\Path (Name is nonexistent or not a directory).
How do i fix this issue?
  댓글 수: 1
Stephen23
Stephen23 2022년 4월 7일
Do not CD just to import/export data files. CD is slow and makes debugging harder.
Every function that import/exports datafiles accepts absolute/relative filenames. You should use absolute/relative filenames.

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2022년 4월 7일
cd(Path).
avoid using 'Path' as variable name as path() is a function.
  댓글 수: 7
Steven Lord
Steven Lord 2022년 4월 7일
If you need to change the current directory, change it once not twice. That's like walking through a door then immediately walking through that same door again -- you end up where you started.
sri satya ravi
sri satya ravi 2022년 4월 8일
Steven,Thanks. That helps.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by