Optimize legend command?

2 vues (au cours des 30 derniers jours)
Muhammad Usman
Muhammad Usman le 8 Déc 2021
Commenté : Muhammad Usman le 8 Déc 2021
Hi, I am struggling with LaTeX in legend, so far I wrote legend like:
legendStrings = string(n);
l = legend(legendStrings);
set(l,'interpreter','latex','string','$x^$'+string(n))
I want legend as and s on, but when I didn't write anything after ^ in string argument, MATLAB show me error.
Note:
n is an array of number and I'm plotting ananoymous function using flot withour loop.
Please optimize these lines and guide me how to display correctly.
Thanks

Réponse acceptée

Matt J
Matt J le 8 Déc 2021
Modifié(e) : Matt J le 8 Déc 2021
For example,
plot((0:4).^2);
s=string(2);
legend("$x^"+s+"$", 'interpreter','latex')
  1 commentaire
Muhammad Usman
Muhammad Usman le 8 Déc 2021
Thank you so very much

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by