Search code examples
matlablatexmatlab-figure

How to write an equation on the ylabel of a figure in MATLAB?


I'm trying to write the following math on the ylabel of a figure in MATLAB,

\norm{\boldsymbol{\tilde{y}}(t)}_2

I've tried this,

ylabel('\norm\boldmath{\bf{$y$}}$(t)$', 'interpreter', 'latex');

But got the following error, Warning: Error updating Text.

Character vector must have valid interpreter syntax: \norm\boldmath{\bf{$y$}}$(t)$

If I use,

ylabel('$|\!|\boldmath{\bf{y}}(t)|\!|_2$', 'interpreter', 'latex');

I get,

enter image description here

but I want the 2-norm of this,

enter image description here


Solution

  • \norm isn't available, but you can use |\!\.

    I can't see a way to do (the revised question) in math, but you can do it in text with \textbf{\emph{y}}.

    ylabel('$|\!|\textbf{\emph{y}}(\mathrm{t})|\!|_2$', 'interpreter', 'latex');
    

    If you don't really want the t to be upright:

    ylabel('$|\!|\textbf{\emph{y}}(t)|\!|_2$', 'interpreter', 'latex');