I just cannot figure out what the problem is with this line, please help. I get this warning sometimes:
Warning: Error updating Text.
Character vector must have valid interpreter syntax:
$ρ_t = 0.26ρ_f, θ_0 = 90°$
Regardless, the subscripts never take. Here is the problematic line:
title(sprintf('$%c_t=%.2f%c_f,%c_0=%2.0f%c$',961,idens,961,952,iang*180/pi,176),'Interpreter','latex');

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 29 Mär. 2018

1 Stimme

latex cannot have any characters with position greater than 255. That is violated by your 961 (rho) and 952 (theta).
Use \rho and \theta

3 Kommentare

xtremecheez
xtremecheez am 29 Mär. 2018
I was not aware of that, but this doesn't quite work either:
title(sprintf('$\rho_t = %.2f\rho_f, \theta_0 = %2.0f%c$',idens,iang*180/pi,176),'interpreter','latex');
nor this with \\greek instead of \greek:
title(sprintf('$\\rho_t = %.2f\\rho_f, \\theta_0 = %2.0f%c$',idens,iang*180/pi,176),'interpreter','latex');
For both I get the following warning:
Character vector must have valid interpreter syntax:
$\rho_t = 0.26\rho_f, \theta_0 = 90°$
Walter Roberson
Walter Roberson am 29 Mär. 2018
The degree character is causing the problem. Use ^{\circ}
xtremecheez
xtremecheez am 29 Mär. 2018
That was it, thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Amirali Kamalian
Amirali Kamalian am 30 Dez. 2019
Bearbeitet: Amirali Kamalian am 30 Dez. 2019

1 Stimme

I have a problem quite similar to this:
pltt = '%1.0u: %4u $^{\circ}$C, %4u kg/h';
...
title(sprintf(pltt, j, T, Q),'FontSize', 12,'Interpreter','latex')
When executing this code, I get the following warning:
"String scalar or character vector must have valid interpreter syntax". Furthermore,
"Warning: Escaped character '\c' is not valid."
Any ideas how to fix this?

2 Kommentare

Stephen23
Stephen23 am 30 Dez. 2019
You forgot to escape the backslash, i.e. \\circ instead of \circ. This is because you are supplying pltt as the format string to sprintf, so any special characters in it that you want to be treated as literal characters will need to be escaped: you should always check the output of sprintf before using it.
Amirali Kamalian
Amirali Kamalian am 30 Dez. 2019
Thanks Stephen!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Labels and Annotations finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by