How to output a decimal format in the use of command Latex?
5 views (last 30 days)
Show older comments
Hi, there? I tried to convert a matrix (calculated by Matlab) to a LaTex format such that I can directly apply it to my LaTex document, I used the _ * Latex*_ command, but the output is not decimal format, how to make its output is in decimal format?
The code and its corresponding output is shown as follows:
W =
0.4237 0.3373 0.2390 0
0.6603 0.3397 0 0
0.6877 0 0 0.3123
0 0 0.6181 0.3819
>> latex_table = latex(sym(W))
latex_table =
\left(\begin{array}{cccc} \frac{4237}{10000} & \frac{3373}{10000} & \frac{239}{1000} & 0\\ \frac{6603}{10000} & \frac{3397}{10000} & 0 & 0\\ \frac{6877}{10000} & 0 & 0 & \frac{3123}{10000}\\ 0 & 0 & \frac{6181}{10000} & \frac{3819}{10000} \end{array}\right)
0 Comments
Accepted Answer
Star Strider
on 27 Feb 2016
Use the vpa funciton:
latex_table = latex(sym(vpa(W)))
latex_table = \left(\begin{array}{cccc} 0.4237 & 0.3373 & 0.239 & 0\\ 0.6603 & 0.3397 & 0 & 0\\ 0.6877 & 0 & 0 & 0.3123\\ 0 & 0 & 0.6181 & 0.3819 \end{array}\right)
I’m no LaTeX expert, but from my experience, you have to begin and end your LaTeX calls with $.
6 Comments
More Answers (0)
See Also
Categories
Find more on Bartlett in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!