Problem with using siunitx (latex) in xlabel, ylabel,

I want to use SI-Units in xlabel and ylabel. It should be interpreted as latex-text.
What I have tried so far:
xlabel('Zeit ($\unit{\second}$)', 'Interpreter', 'latex');
and
xlabel(['Zeit ', '$(\unit{\second})$'], 'Interpreter', 'latex');
Both ways don't work. I get the error:
String scalar or character vector must have valid interpreter syntax:

Respuestas (1)

VBBV
VBBV el 1 de Mayo de 2023
Editada: VBBV el 1 de Mayo de 2023
add another preceding \ as below
xlabel('Zeit $(SI[\\s]$)', 'Interpreter', 'latex');

4 comentarios

Dominik Deml
Dominik Deml el 1 de Mayo de 2023
Editada: Dominik Deml el 1 de Mayo de 2023
I want to use the \unit command to write \second. There shouldn't be a SI. And this still does not work
MATLAB text objects do not support all LaTeX operations or options. There is some guidance on that in the documentation section I linked to here.
So there is no way of doing this?
You will need to be creative!

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 1 de Mayo de 2023

Comentada:

el 1 de Mayo de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by