Created
November 6, 2019 01:03
-
-
Save LemonPi/56c12bb7433bfcb91b6a29a21f2bed6b to your computer and use it in GitHub Desktop.
print matrix/vector in matlab in latex form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function code = bmatrix(X) | |
code = "\\begin{bmatrix}" + newline; | |
rows = size(X, 1); | |
cols = size(X, 2); | |
for i=1:rows | |
for j=1:cols | |
if j == cols | |
code = code + X(i, j) + " \\\\"; | |
else | |
code = code + X(i, j) + " & "; | |
end | |
end | |
code = code + newline; | |
end | |
code = code + "\\end{bmatrix}" + newline; | |
fprintf(code); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment