writing “latex command” in the Matlab figure comme

2019-06-03 11:53发布

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: enter image description here

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条回答
Fickle 薄情
2楼-- · 2019-06-03 12:19

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.

enter image description here

查看更多
登录 后发表回答