Latex to make a figure annotation

20 visualizaciones (últimos 30 días)
ASC
ASC el 18 de Mzo. de 2021
Editada: Cris LaPierre el 19 de Mzo. de 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)

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 19 de Mzo. de 2021
Editada: Cris LaPierre el 19 de Mzo. de 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)

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by