A= [0.7577    0.7060    0.8235    0.4387    0.4898
        0.7431    0.0318    0.6948    0.3816    0.4456
        0.3922    0.2769    0.3171    0.7655    0.6463
        0.6555    0.0462    0.9502    0.7952    0.7094
        0.1712    0.0971    0.0344    0.1869    0.7547]
    latex_table = latex(sym(A));
    I save it as eqA.
                      \frac{6825116339432507}{9007199254740992} & 
                      \frac{6359497797823013}{9007199254740992} & 
                      \frac{3708524368810113}{4503599627370496} & 
                      \frac{987964467329731}{2251799813685248} & 
                      \frac{6693542213068579}{9007199254740992} & 
                      \frac{71681197541747}{2251799813685248} & 
                      \frac{6258459855040489}{9007199254740992} & 
                      \frac{859193262592067}{2251799813685248} & 
                      \frac{55201045594335}{140737488355328} & 
                      \frac{2494300503760379}{9007199254740992} & 
                      \frac{2856178200482939}{9007199254740992} & 
                      \frac{1723790560926853}{2251799813685248} & 
                      \frac{2952009981953243}{4503599627370496} & 
                      \frac{415874915283285}{9007199254740992} & 
                      \frac{8558839330135289}{9007199254740992} & 
                      \frac{3581261978445933}{4503599627370496} & 
                      \frac{770956303438939}{4503599627370496} & 
                      \frac{874885307559191}{9007199254740992} & 
                      \frac{77565677658637}{2251799813685248} & 
                      \frac{1683198784473707}{9007199254740992} & 


        Here we have a nice matrix:


How can I add horizontal and vertical lines and label column and rows of the table. The contents of the table should be updated every time by input eqA. please see imageenter image description here

  • There are other ways of getting a matrix from Matlab to a LaTeX table, e.g. mathworks.de/matlabcentral/fileexchange/4894-matrix2latex See if that does all you want. (It may not work with symbolic stuff, so you won't get the fractions, but from your other question it seems you're after decimals anyway.) – Torbjørn T. Dec 21 '12 at 15:23
  • @ Torbjørn Thanx for ur reply. How can I change your comments as answer, so that I can click this question as answered. – user31177 Jan 1 '13 at 10:15

You can use \hline between the rows to get horizontal lines and | in the array preamble to specify vertical lines. As (again) you have not posted an example that may be run locally I haven't shown the result of adding these.


is a 2x2 example with horizontal and vertical rules.


I used mathworks.de/matlabcentral/fileexchange/4894-matrix2latex and it works well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.