LaTeX in Live Scripts - Using \matrix

335 次查看(过去 30 天)
I want to use the new Live Scripts feature to include a matrix. The usual way of doing this:
\begin{pmatrix} A & B \\ C & D \end{pmatrix}
doesn't work.
The documentation says to use the \matrix command. This works for a row vector:
\pmatrix{a & b}
but not for a column vector or full matrix, i.e.
\matrix{a & b \\ c & d}
How would I render a full matrix in the equation editor within live scripts?

采纳的回答

Sai Kulkarni
Sai Kulkarni 2016-4-25
编辑:Sai Kulkarni 2016-4-25
I understand that you are trying to insert an equation in a Live Script and you are trying to use the LaTeX commands matrix and pmatrix to insert matrices in this equation.
From what I understand, as of MATLAB R2016a, equations in LaTeX only support basic TeX math mode commands. The matrix syntax using begin keyword and \\ operators, which is derived from the amsmath package cannot be used in Live Editor.
However, you can use the following syntax for generating a matrix:
A = \pmatrix{1 & 2 \cr 3 & 4}
This will generate an equation which looks like this:
Same syntax can also be used with matrix to generate a matrix which is not enclosed in parantheses.
I realize that this is not clear from the documentation. I work for MathWorks and I have provided this feedback to the appropriate team.

更多回答(2 个)

uyazgan
uyazgan 2016-12-13
In order to generate matrices with square brackets the following syntax can be used:
A= \left[\matrix{ 1 & 2 \cr 3 &4} \right]
This generates the following matrix:
  1 个评论
Stephanie
Stephanie 2021-1-24
Thank you; I was trying to use LaTeX's "bmatrix" in a Matlab live script and this worked!

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2021-1-24
编辑:Walter Roberson 2023-1-2
I have not checked Live Script, but MATLAB graphics support \begin{array}
It supports a variety of matrix bracket styles. At some point I posted some other examples, but it would take me a while to locate previous posts.

类别

Help CenterFile Exchange 中查找有关 Live Scripts and Functions 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by