how can i fix the "error using cd"?

This is the error
" Error using cd
Cannot CD to /Users/aounqureshi/Master/PV PARAMETERS 2/Data\ (Name is nonexistent or not a directory).
Error in RundatapreprocessingButtonUJA (line 35)
cd(ExportPath); "
how can i fix this error of my GUI app in matlab ?

5 件のコメント

Rik
Rik 2021 年 6 月 8 日
How did you generate the variable ExportPath? And why do you need cd in your code?
Muhammad Aoun Ejaz Qureshi
Muhammad Aoun Ejaz Qureshi 2021 年 6 月 8 日
I had a same error in my windows computer, so place the matlab GUI app in my c drive of my computer and everthing works perfectly, but for macbook i cannot do the same.
Rik
Rik 2021 年 6 月 8 日
You posted the same comment twice, but neither of them actually show the code you're using. You should be using functions like fullfile or filesep. Both me and Steven suspect that you don't.
Muhammad Aoun Ejaz Qureshi
Muhammad Aoun Ejaz Qureshi 2021 年 6 月 8 日
my question is related with the path of app file, which according to the software doesnt exists in my macbook, i am not asking about code.
Rik
Rik 2021 年 6 月 8 日
We are asking about your code. Your error suggests you are hardcoding something you should be doing differently.

サインインしてコメントする。

回答 (2 件)

Steven Lord
Steven Lord 2021 年 6 月 8 日

0 投票

Did you use fullfile to assemble the ExportPath variable, did you manually concatenate pieces together with slashes inbetween, or did you type the whole path out manually? I would probably use fullfile as it would put the right separators between parts of the file path.
That trailing \ looks suspicious as well.

1 件のコメント

Muhammad Aoun Ejaz Qureshi
Muhammad Aoun Ejaz Qureshi 2021 年 6 月 8 日
I had a same error in my windows computer, so place the matlab GUI app in my c drive of my computer and everthing works perfectly, but for macbook i cannot do the same.

サインインしてコメントする。

Walter Roberson
Walter Roberson 2021 年 6 月 8 日
編集済み: Walter Roberson 2021 年 6 月 8 日

0 投票

You need to take the code and convert all \ directory separators in the code into / directory separators, except for some cases involving using system() . [If your code uses dos() or .NET facilities, that part needs to be rewritten anyhow.]
Or you could rewrite the code so that you never explicitly use \ or / as the directory separator at all, and instead use fullfile()
Note that using / to seperate directories is fine in MS Windows, except for use in COMMAND.COM or CMD.EXE or PowerShell . MS Windows uses / internally, not \ -- it is only the command line processing that needs \

カテゴリ

ヘルプ センター および File ExchangeWorkspace Variables and MAT Files についてさらに検索

編集済み:

2021 年 6 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by