Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Project proposal: a scilab (or matlab) code to LaTeX converter
Replies: 9   Last Post: Oct 29, 2001 8:49 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Jan Meyer

Posts: 1
Registered: 12/11/04
Project proposal: a scilab (or matlab) code to LaTeX converter
Posted: Oct 11, 2001 4:56 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,

IMHO one of the greatest short comings of scilab and matlab is that
they don't automatically generate documentation of the code as well as
the results (e.g. compared to MathCad where building the model and
showing which calculations were done in a presentable manner is one
and the same step). Another problem with a pure text presentation (may
it be fontified/colorized) is that one can easily overlook mistakes -
which really reduces productivity.

Since it is especially tedious to copy results that come in matrices
or vectors into LaTeX, I have written a small scilab script that
allows the user to automatically generate a LaTeX table from a couple
of vectors for example with each run of the user's script.

Now I am wondering if there are any packages / any software out there
that converts scilab code into LaTeX code. Sure it would not look
perfect but would be enough for proof reading or form a foundation for
a polished LaTeX document. For example the scilab code:

Cp = F*cos(alpha)/((1+r)^(n-1)-1);

could be translated into:

Cp = F \cdot\cos(alpha) / ((1+r)^{n-1}-1)

... just picture in your head what LaTeX would make of this (e.g. use
different sized parethesies and make the power n-1 much more readable)

if the translation code was a little fancier (i.e. the code could
parse parenthesies and one would use substitution tables for variable
names):

C_p = \frac{F \cdot\cos(\alpha)}{(1+r)^{n-1}-1}

One could even include the result right away if one starts with a
comment that indicates the number format:

Cp = F*cos(alpha)/((1+r)^(n-1)-1) \\F:US\$ %4.2f

resulting in:

C_p = \frac{F \cdot\cos(\alpha)}{(1+r)^{n-1}-1} = US\$ 12.34

[This would probably require the documentation package run as a
preprocessor to the scilab interpreter]

Other statements that contain less math, one could treat with a really
pretty print scheme.

Finally one could display data in automatically generated tables from
the following code:

------------------------
data = yourFunction(parameters); // spits out a 10x4 matrix

//TBegin <--- marks the beginning of a documentation block and is not interpreted
like the rest of the code but simply executed

headings = ["coefficient" "dimensional value" "non-dim. value" "non-dim. factor"];
data = list(data(1), data(2), data(3), data(4));
// The list() keyword creates something like a matrix that can contain
// different data types (one of the nice function of scilab)
formatStr = ["$%s$" "%6.4e" "%6.4e" "%6.4e" "%6.4e"];

// generate a LaTeX table in a separate file called coeffTable.tex
getf('latexTable.sci');
latexTbl("coeffTable.tex", headings, data, formatStr);

//TEnd
----------------

... this would translate to the following LaTeX code:

---------------
data = yourFunction({\bf parameters}); {\small // spits out a 10x4 matrix}

\input{coeffTable.tex}
--------------

A nice fringe affect is that one can convert from LaTeX to HTML or
PDF.

What do you think of this idea? Does such a software exist already for
scilab (or matlab)?

If not: This shouldn't be too much work to code (unless you want
perfect output). Anybody interested in collaborating on this?

- Jan

P.S. please also reply by email to janm@mit.edu (I am having trouble
with my newsgroup server recently)





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.