Convert variable to a title - includes special charcters
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathKat
am 23 Feb. 2015
Bearbeitet: Guillaume
am 23 Feb. 2015
I am storing a file name as a variable to be retrieved. But, the name of the file contains underscores. When I use the variable name as the title of my plot each letter that follows an underscore becomes subscripted. What I would like is for the underscores to remain underscores. Example: FileName=SD_Padres_are_great;
Then I plot a chart & I use this as the title: title(FileName);
In the above example the output title would print with the underscores missing and the P a & g subscripted.
Does anyone know how to keep the title in the exact format of the FileName? BTW-I do not have control of the file names to change them as they are created by another program.
0 Kommentare
Akzeptierte Antwort
Jacob Matthews
am 23 Feb. 2015
You could use the command "strrep" to replace the underscores with spaces:
strrep(FileName,'_',' ')
or if you want to keep the filename exact with the underscores, insert a backslash:
strrep(FileName,'_','\_')
which will print the underscore as an underscore instead of treating it as a indicator for subscripting.
1 Kommentar
Guillaume
am 23 Feb. 2015
Or you could just tell title to not interpret the string as Tex... (set the 'Interpreter' to 'none').
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!