Matrix to Latex


Konvertiert MatlabKeine Zugangsberechtigung- und Octave-Matrizen oder -Vektoren in Latex-Code


Beispiele


Beispiel 1

A = diag(ones(5,1))
at2latex(A, 0)





Beispiel 2

B = rand(5,6)
mat2latex(B, 3)





Beispiel 3

v = rand(5,1) % Vector v
mat2latex(v, 2)






Script


Script für Octave und MatlabKeine Zugangsberechtigung zum formatiren von Matriizen-Werten nach LaTeX.
function s = mat2latex(A,dg)

s = '\begin{pmatrix} ';

[M,N] = size(A);

for m=1:M
    for n=1:N
        s = strcat(s, sprintf([' %0.' num2str(dg) 'f'], A(m,n)) );
        if (n~=N)
            s = strcat(s,' & ');
        end
    end
    if (m~=M)
        s = strcat(s,' \\ ');
    end  
end

s = strcat(s,' \end{pmatrix}');





Siehe auch LatexFormelnKeine Zugangsberechtigung

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki