writing “latex command” in the Matlab figure comme

2019-06-03 12:09发布

问题:

I have a figure in Matlab, inside the figure i would like to write comments on the figure. the comment include latex formula; for example, I want to write this comment on my figure $$ \vec{R} = 2 $$

here is an example that I found when I searched;

clear all;
close all;
clc;
figure
ms = 8;
fontSize = 18;
xx = 0:.1:1;
plot(xx,sin(xx))
xlabel('P_{fa}', 'fontsize', fontSize);
ylabel('P_{m}', 'fontsize', fontSize);

I want it looks like as in the attached figure below:

Note: I searched in last questions that already answered, I found that I can write latex commands in the legend, title, axis ... but not when writing comments inside the figure.

回答1:

Very easy: just add a text object with its 'interpreter' property set to 'latex':

text(.3, .5, '$\vec R=2$', 'interpreter', 'latex', 'fontsize', fontSize)

The first two arguments of text are coordinates; change them as needed.