help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating "Pretty" Report from Octave


From: Jaroslav Hajek
Subject: Re: Creating "Pretty" Report from Octave
Date: Tue, 8 Jun 2010 08:00:18 +0200

2010/6/7 Ian Journeaux <address@hidden>:
> -----Original Message-----
> From: Jaroslav Hajek [mailto:address@hidden
> Sent: Monday, June 07, 2010 2:45 PM
> To: Ian Journeaux
> Cc: Jordi Gutiérrez Hermoso; address@hidden
> Subject: Re: Creating "Pretty" Report from Octave
>
> 2010/6/7 Jordi Gutiérrez Hermoso <address@hidden>:
>> On 7 June 2010 10:36, Ian Journeaux <address@hidden> wrote:
>>> The report I am trying to create would be one or two pages long. I would
>>> like to get a header (Title, sample ID, etc) and footer (page number,
> date,
>>> etc). The body of the report would be several columns of numbers with
> column
>>> headers.
>>
>> I still think you're best off using LaTeX for this. The fancyhdr
>> package should help you get the formatting you want in the headers and
>> footers. As Francesco suggests, you can program the LaTeX generation
>> from within Octave.
>
>
>>I have a nice function matrix2latex (based on a func from Matlab
>>central) for this purpose, that I used several times to generate
>>report tables. I can share if you're interested.
>
> I would love to see it. Thanks for the offer.
>
>

Here goes. It is based on the original code of M. Koehler, but all
inner loops are vectorized or replaced by more efficient constructs,
and it supports rowformats and columnformats options. Also, it can
take an open file handle instead of a file name.
The docstring is not yet texinfoed.

Typical usage looks like this:

        fid = fopen (...);

        matrix2latex (spw_data, fid, ...
          "columnLabels", {"$y$", "$c$", "$\\alpha$", "$c_{Lp}$",
"$c_{Dp}$", "$c_{mp}$",...
                           "$c_N$", "$c_T$", "$c_L$", "$c_D$"}, ...
          "columnFormats", {"%6.3f", "%6.3f", "%5.2f", "%6.3f",
"%8.5f", "%8.5f", ...
                            "%6.3f", "%8.5f", "%6.3f", "%8.5f"}, ...
          "alignment", "r");

it only produces the matrix code itself, you still need to write the
rest of document, such as:

tex_prologue_dl = ["\\documentclass{report}\n% Created by VZLU 17.12.2009\n",...
"\\usepackage[left=4cm,top=1cm,width=15cm,height=25cm,nohead]{geometry}\n", ...
"% Additional settings\n\\begin{document}\\begin{center}\\small{\n"];
fputs (fid, tex_prologue_dl);

...a number of matrix2latex calls...

tex_epilogue_dl = "}\\end{center}\\end{document}\n";
fputs (fid, tex_epilogue_dl);

I suggest you read a LaTeX tutorial if you're a novice. It takes time
to learn, but pays off a hundred times if you're into this sort of
work. Imagine the nightmare of automatic creation of Word or Excel
documents (yes, I used to do that, too, and I loved LaTeX ever since).

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

Attachment: matrix2latex.m
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]