Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB and LaTeX syntax

  1. Sep 9, 2015 #1

    Maylis

    User Avatar
    Gold Member

    Hello,

    I am trying to publish a file on matlab, and for some reason it won't accept my code, even though it works on this forum. Does matlab use some other syntax for matrices?

    $$ \vec {x} = \begin {bmatrix} T-T_{s} \\ C_{A} - C_{As} \\ C_{P} - C_{Ps} \end {bmatrix}$$
    upload_2015-9-9_18-8-31.png
     

    Attached Files:

    Last edited: Sep 9, 2015
  2. jcsd
  3. Sep 10, 2015 #2

    DrClaude

    User Avatar

    Staff: Mentor

    I've never mixed Matlab with LaTeX, but bmatrix is not part of LaTeX, it is an AMS extension.

    You have to do matrices in regular LaTeX "manually," something like
    Code (LaTeX):

    \left[ \begin{array}{c} a \\ b \\ c \end{array} \right]
     
     
  4. Sep 10, 2015 #3

    Maylis

    User Avatar
    Gold Member

    Thank you, that fixed it.
     
  5. Sep 10, 2015 #4

    Maylis

    User Avatar
    Gold Member

    I still don't understand why matlab won't accept this, but the latex on PF will (what is going on with the dCA/dt term !?)

    upload_2015-9-10_13-56-52.png

    $$ \vec {\dot {x}} = \left[ \begin{array}{c} \frac {dT}{dt} \\ \frac
    % {dC_{A}}{dt} \\ \frac {dC_{P}}{dt} \end{array} \right] = \left[ \begin{array}{c} -\frac{F}{V} & F \frac {\Delta H_{rxn}}{\rho V c_{p}} & \frac {\beta}{\rho V c_{p}} \frac {1}{2 \sqrt{C_{P}}} \\ 0 & -\frac {F}{V}-2kC_{A} & 0 \\ 0 & 2kC_{A} & - \frac {F}{V} \end{array} \right] $$
     

    Attached Files:

    Last edited: Sep 10, 2015
  6. Sep 10, 2015 #5

    kreil

    User Avatar
    Gold Member

    According to the doc, http://www.mathworks.com/help/matla...matlab-comments-for-publishing.html#btj5jsh-1

    "MATLAB publishing supports standard LaTeX math mode directives. Text mode directives or directives that require additional packages are not supported."

    So any markup that requires a package (such as amsmath) is out.

    EDIT: It appears that you can add packages by modifying a source file. See this thread for more info:

    http://www.mathworks.com/matlabcentral/newsreader/view_thread/283068
     
    Last edited: Sep 10, 2015
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: MATLAB and LaTeX syntax
  1. MATLAB Syntax (Replies: 3)

  2. MATLAB figure in LATEX (Replies: 5)

Loading...