2

I would like to have the units on the axis from a Matlab plot with the correct form like SIunitx in LATEX. Is this possible?

This is the line that I would like to have different: no u, but μ.

xlabel('C [uF]', 'fontsize', 20,'Interpreter','latex')
3
  • Well seems like you cannot add additional LaTeX packages in Matlab (se.mathworks.com/matlabcentral/answers/…). Exactly how should it be different? I.e., what does it look like now, and how do you want it to look? – Torbjørn T. Aug 24 '19 at 19:36
  • I would like to have micro sign instead of u for example. – tairit Aug 25 '19 at 8:15
  • 3
    Hard to guess when there was no mu in your example. But Matlab understands some TeX syntax (see the dokumentation), so I think you can just write \mu to get that. – Torbjørn T. Aug 25 '19 at 8:25
1

You may need matlab2tikz: https://github.com/matlab2tikz/matlab2tikz

This is a plug-in using tikz, output tikz code from matlab, and modify symbols from the code, with latex compilation

2

Short answer: Just write \mu in your xlabel. Matlab can understand some TeX syntax, see https://se.mathworks.com/help/matlab/ref/text.html#f68-481090_sep_shared-Interpreter (though this does not mean it actually uses TeX).


Addition: as you will see from the Matlab documentation, you can make Matlab use LaTeX to typeset text, with the 'Interpreter', 'LaTeX' option. I've never really used this feature much, and don't really know any details about it. It appears that in earlier versions of Matlab it was possible to add packages to the preamble used, but that changed around 2016 (https://se.mathworks.com/matlabcentral/answers/368641-add-more-latex-packages-for-latex-interpreter-in-matlab#comment_507908). Hence it's not possible to use e.g. siunitx in Matlab.

1

After endless searching on the internet, I didn't find a nice-looking answer, either. Nobody wants a math-italic-µ, followed by a "m" after some space, so it looks like µ m. Then, I asked myself "Why don't you try ASCII characters?" I looked up "µ" on the internet, copied it, pasted it into the plot label/title/etc. of Matlab and was done. It works and looks fine. No awkward font, just the usual one. Should work with all Greek letters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.