Escaped character '\U' is not valid. See 'doc sprintf' for supported special support.

62 Ansichten (letzte 30 Tage)
Hi MATLAB users,
I know it's asked elsewhere on this webpage (https://ww2.mathworks.cn/matlabcentral/answers/435377-warning-escaped-character-u-is-not-valid). However, I have no idea how to fix it as I'm a newbie.
Below is the warning message that I got from the code. How can I edit it to a valid expression in MATLAB R2022b on Windows 11?
Many thanks in advance!
Warning: Escaped character '\U' is not valid. See 'doc sprintf' for supported special
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON
characters.
> In ps_LST_lga (line 254)
In cfg_run_cm (line 29)
In cfg_util>local_runcj (line 1717)
In cfg_util (line 972)
In cfg_ui>MenuFileRun_Callback (line 710)
In gui_mainfcn (line 95)
In cfg_ui (line 53)
Current directory C:Warning: Escaped character '\U' is not valid. See 'doc sprintf' for supported special
characters.
> In ps_LST_lga (line 256)
In cfg_run_cm (line 29)
In cfg_util>local_runcj (line 1717)
In cfg_util (line 972)
In cfg_ui>MenuFileRun_Callback (line 710)
In gui_mainfcn (line 95)
In cfg_ui (line 53)
Warning: Directory already exists.
> In ps_LST_lga (line 290)
In cfg_run_cm (line 29)
In cfg_util>local_runcj (line 1717)
In cfg_util (line 972)
In cfg_ui>MenuFileRun_Callback (line 710)
In gui_mainfcn (line 95)
In cfg_ui (line 53)
Preprocessing of T1.nii 641s
Preprocessing of FLAIR.nii 145s
Coregister FLAIR to T1 91s
Initialize lesions 20-Jan-2023 15:21:31 - Failed 'LST: Lesion segmentation (LGA)'
Out of memory.
In file "C:\MRIapp\toolbox\spm12\toolbox\LST\ps_bwlabeln.m" (???), function "ps_bwlabeln" at line 24.
In file "C:\MRIapp\toolbox\spm12\toolbox\LST\ps_LST_lga.m" (???), function "ps_LST_lga" at line 427.
The following modules did not run:
Failed: LST: Lesion segmentation (LGA)

Akzeptierte Antwort

Jan
Jan am 20 Jan. 2023
Bearbeitet: Jan am 20 Jan. 2023
It is a typical bug under Windows, which does not occur, when the software is tested successfully in Linux:
fprintf(['Current folder: ', cd, '\n'])
The Windows file separators \ are interpreted as escape character for fprintf. Solution:
fprintf('Current folder: %s\n', cd)
Now the path appears as argument of fprintf and is not interpreted.
This concerns sprintf, warning and error message also:
error(['Bad folder: ' cd]) % Wrong output under Windows
error('Bad folder: %s', cd) % Working
Check line 254 of ps_LST_lga.m .
This is another problem: "Warning: Directory already exists." If you show us the corresponding part of the code, suggesting a solution is much easier.
"Out of memory." is not a warning, but a crash.
  4 Kommentare
Krystal Xiwing Yau
Krystal Xiwing Yau am 31 Jan. 2023
Hi Walter Roberson,
I see!
The code for line 290 contains "mkdir(tmpFolder)". The following is the code for your reference:
% Create temporary folder
% ID
id = [num2str(round(rand(1, 1) * 1e4)), '_', num2str(round(rand(1, 1) * 1e4)), '_', num2str(round(rand(1, 1) * 1e4))];
tmpFolder = ['LST_tmp_', id];
mkdir(tmpFolder)
% Preprocessing for T1
Thank you.
Walter Roberson
Walter Roberson am 2 Feb. 2023
Yes, it does, but I do not know why you are pointing that out to me ?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by