matlab中显示latex公式,MATLAB中使用Latex编辑显示公式

本文详细介绍了在MATLAB中如何使用LaTeX编辑和显示数学公式,包括上标、下标、求和、积分、极限、分式、根式等基本格式和命令,并提供了多个实例展示LaTeX的排版效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当键入:>> set(text,'Interpreter')

Matlab将返回'Interpreter'所包含的属性值:

[ latex | {tex} | none ]。

默认值是tex。

Tex的用法在Matlab的帮助文档里有详细介绍,这里主要介绍一下如何采用latex编辑公式。

在matlab中,Latex编辑公式的基本格式:

\( 数学公式 \),或者$ 数学公式 $,或者$$ 数学公式 $$。

常用公式编辑命令:

1.上标用^和下表用_,希腊字母与tex一样,即\alpha表示α等,详见帮助文档“Text

Properties”。

2.求和

$$\sum_{i=1}^{n} x_{i}$$

3.积分

$$ \int_{0}^{1}$$

4.求极限

$$\lim_{n \rightarrow \infty}$$ %n趋于无穷符号在lim正下方

$\lim_{n \rightarrow \infty} $ %趋于无穷符号在lim右下角

5. 分式

$$\frac{1}x$$ %1/x

6. 根式

$$\sqrt{x}$$

7. 上划线

$$\overline{x}$$

8. 下划线

$$\underline{x}$$ %下划线在x的正下方

9.卧式花括号命令

$$\overbrace{x+y+z+w}$$

10.仰式花括号命令

$$a+\underbrace{b+c+d} $$

11.戴帽命令

$$\hat{o}\ \ \check{o}\ \ \breve{o}$$

$$\widehat{A+B} \ \ \widetilde{a+b}$$

$$\vec{\imath}+\vec{\jmath}=\vec{k}$$

12.堆砌命令

$$y\stackrel{\rm def}{=} f(x) \stackrel{x\rightarrow

0}{\rightarrow} A$$

13.省略号

$\cdots \ldots \vdots \ddots $

Example — Using LaTeX to Format Math Equations

The LaTeX markup language evolved from TEX, and has a superset of

its capabilities. LaTeX gives you more elaborate control over

specifying and styling mathematical symbols.

The following example illustrates some LaTeX typesetting

capabilities when used with the text function. Because the default

interpreter is for TEX, you need to specify the parameter-value

pair 'interpreter','latex' when typesetting equations such as are

contained in the following script:

%% LaTeX Examples--Some well known equations rendered in

LaTeX

%

figure('color','white','units','inches','position',[2 2 4

6.5]);

axis off

%% A matrix; LaTeX code is

% \hbox {magic(3) is } \left( {\matrix{ 8 & 1

& 6 \cr

% 3 & 5 & 7 \cr 4 &

9 & 2 } } \right)

h(1) = text('units','inch', 'position',[.2 5], ...

'fontsize',14, 'interpreter','latex', 'string',...

['$$\hbox

{magic(3) is } \left( {\matrix{ 8 & 1

& 6 \cr'...

'3

& 5 & 7 \cr 4 & 9

& 2 } } \right)$$']);

%% A 2-D rotation transform; LaTeX code is

% \left[ {\matrix{\cos(\phi) &

-\sin(\phi) \cr

% \sin(\phi) & \cos(\phi)

\cr}}

% \right] \left[ \matrix{x \cr y} \right]

%  % $$ \left[ {\matrix{\cos(\phi)

% & -\sin(\phi) \cr \sin(\phi)

& \cos(\phi) % \cr}}

% \right] \left[ \matrix{x \cr y} \right]

$$

%

h(2) = text('units','inch', 'position',[.2 4], ...

'fontsize',14, 'interpreter','latex', 'string',...

['$$\left[

{\matrix{\cos(\phi) & -\sin(\phi) \cr'...

'\sin(\phi)

& \cos(\phi) \cr}} \right]'...

'\left[

\matrix{x \cr y} \right]$$']);

%% The Laplace transform; LaTeX code is

% L\{f(t)\} \equiv F(s) = \int_0^\infty\!\!{e^{-st}f(t)dt}

% $$ L\{f(t)\} \equiv F(s) =

\int_0^\infty\!\!{e^{-st}f(t)dt} $$

% The Initial Value Theorem for the Laplace

transform:

% \lim_{s \rightarrow \infty} sF(s) = \lim_{t

\rightarrow 0} f(t)

% $$ \lim_{s \rightarrow \infty} sF(s) = \lim_{t

\rightarrow 0}

% f(t) $$

%

h(3) = text('units','inch', 'position',[.2 3], ...

'fontsize',14, 'interpreter','latex', 'string',...

['$$L\{f(t)\} \equiv F(s) =

\int_0^\infty\!\!{e^{-st}'...

'f(t)dt}$$']);

%% The definition of e; LaTeX code is

% e = \sum_{k=0}^\infty {1 \over {k!} }

% $$ e = \sum_{k=0}^\infty {1 \over {k!} }

$$

%

h(4) = text('units','inch', 'position',[.2 2], ...

'fontsize',14, 'interpreter','latex', 'string',...

'$$e =

\sum_{k=0}^\infty {1 \over {k!} } $$');

%% Differential equation

% The equation for motion of a falling body with air

resistance

% LaTeX code is

% m \ddot y = -m g + C_D \cdot {1 \over 2} \rho

{\dot y}^2 \cdot A

% $$ m \ddot y = -m g + C_D \cdot {1 \over 2}

\rho {\dot y}^2

% \cdot A $$

%

h(5) = text('units','inch', 'position',[.2 1], ...

'fontsize',14, 'interpreter','latex', 'string',...

['$$m \ddot

y = -m g + C_D \cdot {1 \over 2}'...

'\rho {\dot

y}^2 \cdot A$$']);

%% Integral Equation; LaTeX code is

% \int_{0}^{\infty} x^2 e^{-x^2} dx =

\frac{\sqrt{\pi}}{4}  % $$ \int_{0}^{\infty} x^2 e^{-x^2} dx =

\frac{\sqrt{\pi}}{4} $$  %  h(6) = text('units','inch', 'position',[.2 0], ...

'fontsize',14, 'interpreter','latex', 'string',...

'$$\int_{0}^{\infty} x^2 e^{-x^2} dx =

\frac{\sqrt{\pi}}{4}$$'); a4c26d1e5885305701be709a3d33442f.png

a4c26d1e5885305701be709a3d33442f.pnga4c26d1e5885305701be709a3d33442f.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值