How can I write with latex character in xlabel in matlab

Viewed 28

I would write my xlabel with Latec character so I used this code

x = -10:0.1:10;
y = [sin(x); cos(x)];
plot(x,y)
xlabel('$\mathbb{x}$','Interpreter','latex')

but I have this warning message

Warning: Error updating Text.

String scalar or character vector must have valid interpreter syntax: $\mathbb{x}$

and the xlabel appear like this https://i.stack.imgur.com/NCI4n.png

please how I can fix this problem.

1 Answers

The problem with your example is the mathbb command, which is not in base Latex. To show this, replace the \mathbb with, e.g., \mathrm. This will work.

I've never seen an example of adding Latex packages into the Matlab environment. (Update below)


You can have a look at this question, which includes a very aggressive potential way to add the package you need. But it's not clear to me if the solution proposed is actually functional.

How do you use the LaTeX blackboard font in MATLAB?

Related