Latex en la leyenda de los graficos

9 views (last 30 days)
Mauro Gonzalez
Mauro Gonzalez on 10 May 2023
Edited: VBBV on 10 May 2023
¿Por que la leyenda del grafico no me toma la fuente de latex?
x=[0:0.02:1];
u1=0.13-1.37.*x+1.9.*x.^2-1.11.*x.^3-0.88.*x.^4;
u2=0.13-1.46.*x+0.09.*x.*(1-x)+1.99.*x.^2.*(1-x)+0.88.*x.^3.*(1-x);
plot(x,u1);
hold on;
grid on;
plot(x,u2,'k--');
legend('u','\hat{u}','interpreter','latex');
xlabel('$x$','interpreter','latex')
ylabel('$u \hspace{3mm} \hat{u}$','interpreter','latex')
Warning: Error updating Legend.

String scalar or character vector must have valid interpreter syntax:
\hat{u}

Answers (2)

Walter Roberson
Walter Roberson on 10 May 2023
'$\hat{u}$'

VBBV
VBBV on 10 May 2023
Edited: VBBV on 10 May 2023
you can use the $\hat{u}$ in legend function , The latex interpreter fonts usually appear smaller compared to regular fontsize.
x=[0:0.02:1];
u1=0.13-1.37.*x+1.9.*x.^2-1.11.*x.^3-0.88.*x.^4;
u2=0.13-1.46.*x+0.09.*x.*(1-x)+1.99.*x.^2.*(1-x)+0.88.*x.^3.*(1-x);
plot(x,u1);
hold on;
grid on;
plot(x,u2,'k--');
%
legend('u','$\hat{u}$','interpreter','latex','fontsize',18)
xlabel('$x$','interpreter','latex','fontsize',18)
ylabel('[$u ,\hspace{3mm} \hat{u}$]','interpreter','latex','fontsize',18)

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!