Latex to make a figure annotation

20 vues (au cours des 30 derniers jours)
ASC
ASC le 18 Mar 2021
Modifié(e) : Cris LaPierre le 19 Mar 2021
I would like to the Latex interpreter to create a textbox for a figure (see below). When I try to use numbers as strings it works fine. When I use a string or character vector, I get errors. Any suggestions?
x = [1:10];
y = 2 * x;
plot(x,y)
%a = 'Al2O3'; % this line does not work
a = num2str(1.0); % this line does work
b = num2str(1.1);
c = num2str(1.2);
d = num2str(1.3);
abcd = strcat('$\matrix{Material & Thickness (A) & Roughness (A) & \rho (g/cm^{3}) \cr ', a, '&', b, '&', c, '&', d, '}$')
annotation("textbox",'interpreter','latex','string', abcd)
  1 commentaire
ASC
ASC le 19 Mar 2021
Thank you very much!

Connectez-vous pour commenter.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 19 Mar 2021
Modifié(e) : Cris LaPierre le 19 Mar 2021
Just my opinion, but MATLAB does not support all LaTeX libraries. I built your array interactively in the equation editor and then borrowed from the LaTex command for that to come up with something that does work.
x = [1:10];
y = 2 * x;
plot(x,y)
a = 'Al2O3';
b = num2str(1.1);
c = num2str(1.2);
d = num2str(1.3);
abcd = "$\begin{array}{cccc}Material & Thickness(A) & Roughness(A) & \rho (g/{cm}^3)\\" ...
+ a + "&" + b + "&" + c + "&" + d + "\end{array}$"
abcd = "$\begin{array}{cccc}Material & Thickness(A) & Roughness(A) & \rho (g/{cm}^3)\\Al2O3&1.1&1.2&1.3\end{array}$"
annotation("textbox",'interpreter','latex','string', abcd)

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by