Latex to make a figure annotation

조회 수: 20 (최근 30일)
ASC
ASC 2021년 3월 18일
편집: Cris LaPierre 2021년 3월 19일
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
ASC
ASC 2021년 3월 19일
Thank you very much!

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 3월 19일
편집: Cris LaPierre 2021년 3월 19일
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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by