How to Generate Subscripted Arrays in Live Scripts

조회 수: 3 (최근 30일)
fa wu
fa wu 2024년 4월 14일
댓글: fa wu 2024년 4월 17일
I would like to generate the following array or matrix. The symbolic variable Z needs to have a subscript of 1。And can be used in subsequent symbolic operations.
or
Currently, I can generate the following effects in Live Scripts.
There are three problem::
1. I cannot obtain or on the left side of the equal sign; I can only get Z on the left side of the equal sign.
2. The output results copied as LaTeX code do not include Z; they only include the vector itself.I would like the LaTeX code in the output to include or
3、How to convert round parentheses of a vector to square brackets
Screenshots of Live Scripts:
I copied LaTeX code like the image below.
latex code:
\left(\begin{array}{ccc}
z_1 & z_2 & z_3
\end{array}\right)
  댓글 수: 1
Paul
Paul 2024년 4월 14일
The shape of the brackets can be controlled with sympref.
Do you want to only generate a latex string for some other use, like in the title of a plot?
Or do you also want to display the equation with the typset Z_1 on the left hand side in the live script itself?

댓글을 달려면 로그인하십시오.

답변 (2개)

VBBV
VBBV 2024년 4월 14일
\left(\begin{array}{ccc}
z_{1} & z_{2} & z_{3}
\end{array}\right)
  댓글 수: 2
VBBV
VBBV 2024년 4월 14일
편집: VBBV 2024년 4월 15일
use '{' '}' curly braces to enclose numbers for obtaining subscripts. e.g if you want to have it for Z or Za then you need to
Z_{1}
Z_{a}
For output of square brackets you can use sympref function and set the output to square brackets as true
fa wu
fa wu 2024년 4월 14일
Thank you for your response
This is the effect displayed by the LaTeX code you provided. I didn’t notice any changes. Or maybe I didn’t understand what you meant?”

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2024년 4월 14일
You cannot get a formatted output of
When you have an assignment such as
Z_a = sym('z', [1 3])
Z_a = 
then the display never formats the left hand side symbol.
and if you try
Z = sym('z', [1 3]);
syms Z_a
Z_a == Z
ans = 
The expansion of the comparisons is done before the output.
  댓글 수: 3
Walter Roberson
Walter Roberson 2024년 4월 16일
Z = sym('z', [1 3]);
syms Z_a
sympref('MatrixWithSquareBrackets', 1)
ans = logical
0
Z_a == Z
ans = 
sympref('MatrixWithSquareBrackets', 0)
ans = logical
1
Z_a == Z
ans = 
fa wu
fa wu 2024년 4월 17일
Thanks for your comment

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by