Latex to make a figure annotation

30 Ansichten (letzte 30 Tage)
ASC
ASC am 18 Mär. 2021
Bearbeitet: Cris LaPierre am 19 Mär. 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)

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 19 Mär. 2021
Bearbeitet: Cris LaPierre am 19 Mär. 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)

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by