issue with using a variable for path name

3 次查看(过去 30 天)
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.

请先登录,再进行评论。

更多回答(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