Why won't MATLAB accept my bmatrix syntax?

  • Topic: MATLAB 
  • Thread starter gfd43tg
  • Start date
  • Tags Tags
    Latex Matlab
4 replies · 3K views · last reply
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}$$
Screenshot of MATLAB live editor errors: two LaTeX bmatrix equations for vector x and vector u, each followed by an 'Error updating Text' message and red interpreter syntax error text.
 
Attachments
  • Screenshot of a MATLAB publish HTML page showing equations for a CSTR model and red error messages reporting that bmatrix code is not valid interpreter syntax.
    upload_2015-9-9_16-38-44.png
    36.1 KB · Views: 920
Last edited:
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
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 !?)

Rendered equation: x-dot vector equals a column of dT/dt, dC_A/dt, dC_P/dt, equal to a 3x3 matrix times the state, with entries involving F, V, DeltaH_rxn, rho, c_p, beta, k and C_A.


$$ \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
  • Typeset equation: x-dot vector equals a column of time derivatives dT/dt, dC_A/dt and dC_P/dt, followed by a 3x3 matrix of terms involving F, V, k, C_A, Delta H_rxn, rho, c_p and beta.
    upload_2015-9-10_13-55-48.png
    7.3 KB · Views: 609
  • Rendered LaTeX matrix equation: a column vector of time derivatives of T, C_A and C_P equals a 3x3 matrix of terms including F/V, Delta H_rxn over rho V c_p, and beta over rho V c_p times 1 over 2 sqrt(C_P).
    upload_2015-9-10_13-57-2.png
    7.5 KB · Views: 604
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