MATLAB MATLAB & LaTeX Syntax Solutions

  • Thread starter Thread starter gfd43tg
  • Start date Start date
  • Tags Tags
    Latex Matlab
Click For Summary
MATLAB has specific requirements for publishing files that differ from standard LaTeX syntax, particularly regarding matrix formatting. The use of the bmatrix environment, which is part of the AMS LaTeX extension, is not supported in MATLAB. Instead, matrices must be formatted manually using the array environment. This discrepancy explains why certain LaTeX code works on forums but not in MATLAB. Additionally, MATLAB publishing only supports standard LaTeX math mode directives, and any markup requiring additional packages, like amsmath, is not accepted. However, it is possible to include additional packages by modifying a source file, as referenced in a related thread.
gfd43tg
Gold Member
Messages
947
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: 872
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 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: 563
  • upload_2015-9-10_13-57-2.png
    upload_2015-9-10_13-57-2.png
    7.5 KB · Views: 554
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 gfd43tg

Similar threads

Replies
6
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 7 ·
Replies
7
Views
4K