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 Center および File ExchangeSearch Path についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by