convert Matlab array to Latex
65 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have an array of cells which I want to convert into a latex table.
I know for a simple array I can use the following command:
A = [1 2 3; 4 5 6; 7 8 9];
latex_table = latex(sym(A))
Which will create
latex_table =
\left(\begin{array}{ccc} 1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9 \end{array}\right)
However, if I have something like this
B = ['Hello World' '2' '3'; 'yes' 'a' '6'; 'yes' '8' 'john']
How can I create a latex table from the matrix B?
0 comentarios
Respuestas (1)
Daksh
el 2 de Feb. de 2023
You can use the MATLAB latex() method to convert the MATLAB Array into latex table as follows:
B=["Hello" "2" "3"; "yes" "5" "6"; "Sam" "8" "John"];
latex_table = latex(sym(B))
If you intend to store "Hello World" inside the 1st element of the MATLAB array, it will yield an error while creating Latex table as it doesn't allow the same. For that, you can use the str2sym() method as follows:
B=[str2sym("Hello world") "2" "3"; "yes" "5" "6"; "Sam" "8" "John"];
latex_table = latex(sym(B))
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre LaTeX 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!