MATLAB——特殊符号的输入

利用MATLAB编程绘图时,有时需要在标题、坐标轴中添加数学公式、希腊字母等特殊字符,此时利用LaTex语句即可完美插入相关内容,现将部分LaTex语法以及常用特殊符号汇总如下:

一、对MATLAB生成的图形标注

MATLAB图形中title、xlabel、ylabel、zlable、textbox、legend等的Interpreter属性包括latex、tex和none,其中默认为tex。需要使用LaTex时,将Interpreter属性设置为latex。在MATLAB中使用LaTex的格式有三种:

1、\( Latex Command \)
2、$ LaTex Command $
3、$$ LaTex Command $$

 案例:

x = 0:0.1:2*pi;
y1 = sin(x);
y2 = cos(x)*0.5;
plot(x,y1,x,y2);
legend({'y = sin(x)','$$ y = \frac{cos(x)}{2}$$'},'interpreter','latex');
set(gcf,'unit','centimeters','Position',[4 2 12 5.5]); % 设置图片大小与位置

二、具体公式编辑

2.1 字符位置设置

序号需求函数字符结构示例
1上角标^{ }title( '$ a^2 + b^2 = c^2 $ ', 'interpreter', 'latex')
2下角标_{ }title( '$  a_2 + b_2 = c_{bd} $', 'interpreter', 'latex' )

2.2 字符字体设置

1、字体加粗:\bf{ x }

2、字体倾斜1:\it{ x }

3、字体倾斜2:\sl{ x }

4、正常字体:\rm{ x }

5、设置字体名:\fontname{ 字体名 }

6、设置字体大小:\fontsize{ 字体大小 } 

7、设置字体颜色:\color{ red }

可用颜色包括:red、green、yellow、magenta、blue、black、white、cyan、gray、barkGreen、orange、lightblue。

% Demo
x = -5:0.05:5;
y = x.^3 + 1;
plot(x,y);
grid on;
title('$y = x^2 + a_0 + \bf{A_1} + \it{A_2} + \sl{A_3}$','interpreter','latex');
set(gcf,'unit','centimeters','Position',[4 2 12 5.5]); % 设置图片大小与位置

2.3 具体公式编辑

1、求和运算:\sum_{ i=1 }^{ n }

2、积分运算:\int_{ x_1 }^{ x_2 }

3、极限运算:

$$\lim_{n \rightarrow \infty}$$    % n趋于无穷符号在lim正下方
$\lim_{n \rightarrow \infty}$      % n趋于无穷符号在lim右下角
% 区别是符号在正下方左右各用了2个$符号,符号在右下角左右各用了1个$符号

4、分式运算:\frac{ x^2 + y^2 } { x+y+z } 

% Demo
x = -5:0.05:5;
y1 = x.^3 + 1;
y2 = x.^3 ;
plot(x,y1,x,y2);
grid on;
title('$ y = \sum_{i=1}^{n}x_{i} + \frac{1}{2} + \int_{0}^{5}x$','interpreter','latex');
legend({'$$\lim_{n \rightarrow \ infty}$$','$ \lim_{n \rightarrow \ infty} $'},'interpreter','latex')
set(gcf,'unit','centimeters','Position',[4 2 12 5.5]);% 设置图片大小与位置

5、根式运算:\sqrt{ x^2 + y^2 }

6、上划线:\overline{ x }

7、下划线:\underline{ x }

8、卧式花括号:\overbrace{ x+y+z }

% Demo
x = -5:0.05:5;
y = x.^3 + 1;
plot(x,y);
grid on;
title('$y = x^2 + \overline{x} + \underline{x} + \sqrt{x} + \overbrace{x+y}$','interpreter','latex');
set(gcf,'unit','centimeters','Position',[4 2 12 5.5]); % 设置图片大小与位置

 9、仰视花括号:\underbrace{ a+b+c }

10、戴帽命令:\hat{ x }、\check{ x }、\breve{ x }、\widehat{ A+B }、\widetilde{ a+b }、\vec{ x }、\vec{ \imath }

11、堆砌命令:\stackrel{ \rm def }{ = } f(x)

12、省略号:\cdots、\ldots、\vdots、\ddots

% Demo
x = -5:0.05:5;
y = x.^3 + 1;
plot(x,y);
grid on;
title('$\underbrace{x+y} + \hat{x} + \check{x} + \breve{x} + \vec{\imath} + y \stackrel{\rm def}{=} + \cdots + \ldots +\vdots +\ddots$ ','interpreter','latex');
set(gcf,'unit','centimeters','Position',[4 2 12 5.5]); % 设置图片大小与位置

三、特殊符号汇总

表1 特殊符号
序号函数字符表征符号函数字符表征符号函数字符表征符号
1

\alpha

α

\upsilon

υ

\sim

~

2

\angle

\phi

Φ

\leq

3

\ast

*

\chi

χ

\infty

4

\beta

β

\psi

ψ

\clubsuit

5

\gamma

γ

\omega

ω

\diamondsuit

6

\delta

δ

\Gamma

Γ

\heartsuit

7

\epsilon

ɛ

\Delta

Δ

\spadesuit

9

\zeta

ζ

\Theta

Θ

\leftrightarrow

10

\eta

η

\Lambda

Λ

\leftarrow

11

\theta

Θ

\Xi

Ξ

\Leftarrow

12

\vartheta

ϑ

\Pi

Π

\uparrow

13

\iota

ι

\Sigma

Σ

\rightarrow

14

\kappa

κ

\Upsilon

ϒ

\Rightarrow

15

\lambda

λ

\Phi

Φ

\downarrow

16

\mu

µ

\Psi

Ψ

\circ

º

17

\nu

ν

\Omega

Ω

\pm

±

18

\xi

ξ

\forall

\geq

19

\pi

π

\exists

\propto

20

\rho

ρ

\ni

\partial

21

\sigma

σ

\cong

\bullet

22

\varsigma

ς

\approx

\div

÷

23

\tau

τ

\Re

\neq

24

\equiv

\oplus

\aleph

25

\Im

\cup

\wp

26

\otimes

\subseteq

\oslash

27

\cap

\in

\supseteq

28

\supset

\lceil

\subset

29

\int

\cdot

·

\o

ο

30

\rfloor

\neg

¬

\nabla

31

\lfloor

\times

x

\ldots

...

32

\perp

\surd

\prime

´

33

\wedge

\varpi

ϖ

\0

34

\rceil

\rangle

\mid

|

35

\vee

\langle

\copyright

©

  • 57
    点赞
  • 449
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值