How can I insert matrices I've created in Matlab into the Latex equation editor?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
How can I insert matrices I've created in Matlab into the Latex equation editor? To elaborate, I would like to know how I can generate a matrix for example:
Lets all ...
A = magic(5)
B =
[ 1 2 3 4 5
6 7 8 9 10
1 2 3 4 5
6 7 8 9 10
1 2 3 4 5]
The ouput of C = B*A is:
C =
170 190 255 190 170
495 515 580 515 495
170 190 255 190 170
495 515 580 515 495
170 190 255 190 170
Is there a way using only code to display "C" as a matrix that is displayed via Latex equation editor?
If you plug the following into the Latex equation editor by hand
C = \left[\matrix{
170 &190 & 255 & 190 & 170 \cr
495 & 515 & 580 & 515 & 495 \cr
170 & 190 & 255 & 190 & 170 \cr
495 & 515 & 580 & 515 & 495 \cr
170 & 190 & 255 & 190 & 170}\right]
the result should be the Latex generated Matrix shown below shown below:

0 comentarios
Respuestas (1)
Walter Roberson
el 9 de Feb. de 2021
"Is there a way using only code to display "C" as a matrix that is displayed via Latex equation editor?"
Yes there is.
The latex equation editor is only applicable to mlx -- that is, to Live Script. mlx files are zipped directories of XML files, with structure similar to to Excel xlsx files, using Open XML rules (or close to them.)
Therefore it is possible to write code that will take a numeric matrix and generate latex for it and drop it into an XML file in a directory of XML files, and then zip the directory up and name the result as mlx. And then you can request that matlab open the mlx file in the editor.
You might need to generate MathML for some of the components along the way.
... I didn't say it would be easy or that there would be tools for it, just that it could be done "just in code".
Note: if you have the symbolic toolbox then latex(sym(C, 'f')) can help generate the latex itself. latex(sym(C)) would do the same except it attempts to convert to rationals and square roots of rationals along the way.
0 comentarios
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!