[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: putting a matrix in LaTeX-format [newbie]
From: |
c. |
Subject: |
Re: putting a matrix in LaTeX-format [newbie] |
Date: |
Sat, 17 Dec 2011 12:22:11 +0100 |
On 17 Dec 2011, at 10:19, BVBA NuKey Music wrote:
> Is there a function in octave which produces the necessary LaTeX-code
> starting from an array with data was produced by Octave.
> Now I have each time to copy/paste the result in my LaTeX-document, add an &
> between each value and terminate each row with a \\, then add the following
> lines:
> \begin{displaymath}
> \mathbf{X}=
> \left(\begin{array}{ccc......c}
>
>
>
> \end{array}\right)
> \end{displaymath}
>
> thanks in advance
> nukey
> _____
Or, you could use the one below,
that I found among my own scripts.
c.
## Copyright (C) 2011 Carlo de Falco <cdf _AT_ users.sourceforge.net>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
function printlatextable(colheaders,rowheaders,data,filename)
f = fopen(filename,"w");
%%table format
fprintf(f,["\\begin{tabular} { c | *{ %d }{ >\\scriptsize c} }"
" \n \\toprule \n"],\
columns(data));
%%column headers
for ii = 1:columns(data)
fprintf(f,[ "&" colheaders{ii}]);
end
fprintf(f,"\\\\ \\midrule \n");
%%row headers and row data
for ii = 1:rows(data)
fprintf(f,rowheaders{ii});
fprintf(f,"& %.3g",data(ii,:));
fprintf(f,"\\\\ \n");
end
fprintf(f,"\\end{tabular}");
fclose(f);
endfunction
Re: putting a matrix in LaTeX-format [newbie], Joseph C. Slater PE, PhD, 2011/12/19