Hi
I've wrote an function that exports a matrix into latex tabular format

http://paste.osuv.de/index.php/k69/

I would contribute that to Octave/Octave-Forge IO Package if there's
an interest in.

greetings
Markus

## -*- texinfo -*-
## This function save you matrix in Latex table (tabular) format with
right alignment
##
## @example
## matrix2textable ([1 4; 7.5 2], "example.tex")
##
##\begin@{tabular@}@{|r|r|@}
## \hline
##1 & 4 \\
## \hline
##7.5 & 2 \\
## \hline
##\end@{tabular@}
## @end example
##
## @example
## matrix2textable (A, "my-A-Matrix.tex")
## @end example

function matrix2textable(data,filename)
        f = fopen(filename,"w");
        fprintf(f, ["\\begin{tabular}{|%s}\n"], repmat 
('r|',[1,columns(data)]));
# row data
        fprintf(f," \\hline \n");
        for ii = 1:rows(data)
                fprintf(f,"%g",data(ii,1));
                fprintf(f," & %g",data(ii,2:end));
                fprintf(f," \\\\ \n \\hline \n");
        end
        fprintf(f,"\\end{tabular}\n");
        fclose(f);
endfunction

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to