Character string error only in no desktop mode

I am learning how to run MATLAB (I have 2022a) without a GUI.
Currently I'm trying to add a path on no desktop mode.
I'm opening MATLAB using the command prompt via
matlab -nodesktop
and using
userpath("C:\Users\LouisDavis\Documents\MATH\Masters 2022&23\Thesis\Matlab code")
This runs correctly when I open matlab with a GUI
I'm getting the error "Error: String is not terminated properly" on no desktop mode. And if I replace the above with
userpath('C:\Users\LouisDavis\Documents\MATH\Masters 2022&23\Thesis\Matlab code')
The error becomes "Error: Character vector is not terminated properly."
Any help would be much appreciated.

6 件のコメント

Walter Roberson
Walter Roberson 2022 年 4 月 22 日
How are you submitting those userpath() commands to MATLAB's command line? Are they already stored in a .m file and you are telling MATLAB to run that file? Or are you sending them via I/O redirection or writing them to a file from something else and telling MATLAB to run the file ?
Louis Davis
Louis Davis 2022 年 4 月 22 日
Just by entering them directly at the prompt/command line
Walter Roberson
Walter Roberson 2022 年 4 月 22 日
Mumble... mumble...
I wonder if it would make a difference if you were to rename the directory to not have the & character? It "shouldn't" -- but just maybe the &23 is being interpreted as char(23)
Mumble... mumble...
What system codepage do you have set up for the keyboard? What language do you have configured for your system?
Louis Davis
Louis Davis 2022 年 4 月 22 日
I tried renaming the file without the & and I still received the same error.
My windowscodepage is 1252, system language is English(US).
If you'd like anything else please let me know.
Walter Roberson
Walter Roberson 2022 年 4 月 22 日
I think I am out of ideas :(
Louis Davis
Louis Davis 2022 年 4 月 23 日
That's OK, thanks for your suggestions

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

回答 (2 件)

Shanmuganathan
Shanmuganathan 2022 年 10 月 28 日

0 投票

Hi Louis,
I understand you are facing an issue with adding user paths in MATLAB "nodesktop" mode.
I tried adding a similar folder structure to my user path and it seems to be working fine in MATLAB with "-nodesktop" flag.
The folder specified using userpath appears on the search path immediately, and at startup in future sessions. Hence, you can add the user path from regular MATLAB and use it in MATLAB with "-nodesktop" flag.
Regards,
Shanmuganathan
Steven Lord
Steven Lord 2022 年 10 月 28 日

0 投票

Do the commands appear to have extra line breaks inserted into them? If so see this Answers post.

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

リリース

R2022a

タグ

質問済み:

2022 年 4 月 22 日

回答済み:

2022 年 10 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by