Latex to make a figure annotation

31 visualizzazioni (ultimi 30 giorni)
ASC
ASC il 18 Mar 2021
Modificato: Cris LaPierre il 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)

Risposta accettata

Cris LaPierre
Cris LaPierre il 19 Mar 2021
Modificato: Cris LaPierre il 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)

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by