MATLAB & LaTeX Syntax Solutions

  • Context: MATLAB 
  • Thread starter Thread starter gfd43tg
  • Start date Start date
  • Tags Tags
    Latex Matlab
Click For Summary

Discussion Overview

The discussion revolves around the compatibility of MATLAB syntax with LaTeX formatting, particularly in the context of publishing documents. Participants explore issues related to matrix representation and the use of LaTeX commands within MATLAB.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant questions whether MATLAB uses a different syntax for matrices compared to LaTeX, citing a specific matrix code that works in the forum but not in MATLAB.
  • Another participant notes that the 'bmatrix' command is not part of standard LaTeX but rather an AMS extension, suggesting an alternative method for creating matrices in LaTeX.
  • A later reply expresses gratitude for the alternative solution provided, indicating it resolved their issue.
  • Another participant expresses confusion about why MATLAB does not accept certain LaTeX commands, particularly regarding the derivative notation in their matrix representation.
  • A participant references MATLAB documentation, stating that MATLAB publishing supports standard LaTeX math mode directives but not those requiring additional packages, such as amsmath.
  • It is mentioned that packages can potentially be added by modifying a source file, with a link to a related thread for further information.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the reasons for MATLAB's syntax limitations, and multiple views on the compatibility of LaTeX commands with MATLAB remain evident.

Contextual Notes

Limitations include the unclear distinction between standard LaTeX commands and those requiring additional packages, as well as the specific conditions under which MATLAB accepts or rejects certain syntax.

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: 890
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: 578
  • upload_2015-9-10_13-57-2.png
    upload_2015-9-10_13-57-2.png
    7.5 KB · Views: 567
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

Similar threads

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