Why won't MATLAB accept my bmatrix syntax?

  • Context: MATLAB 
  • Thread starter Thread starter gfd43tg
  • Start date Start date
  • Tags Tags
    Latex Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 3K views
gfd43tg
Gold Member
Messages
949
Reaction score
48
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
 

Attachments

  • upload_2015-9-9_16-38-44.png
    upload_2015-9-9_16-38-44.png
    36.1 KB · Views: 908
Last edited:
Physics news on Phys.org
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:
\left[ \begin{array}{c} a \\ b \\ c \end{array} \right]
 
  • Like
Likes   Reactions: gfd43tg
Thank you, that fixed it.
 
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] $$
 

Attachments

  • upload_2015-9-10_13-55-48.png
    upload_2015-9-10_13-55-48.png
    7.3 KB · Views: 595
  • upload_2015-9-10_13-57-2.png
    upload_2015-9-10_13-57-2.png
    7.5 KB · Views: 590
Last edited:
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:
  • Like
Likes   Reactions: gfd43tg