Skip to content

Instantly share code, notes, and snippets.

@jberkman
Last active October 31, 2020 18:22
Show Gist options
  • Save jberkman/9b0f80860add8b10e7c62815cb0baaff to your computer and use it in GitHub Desktop.
Save jberkman/9b0f80860add8b10e7c62815cb0baaff to your computer and use it in GitHub Desktop.
function m2l(A, fname, type)
if nargin < 3
type = 'bmatrix';
end
[ m, n ] = size(A);
fp = fopen(fname, 'w');
fprintf(fp, '\\begin{%s}\n', type);
for i = 1:m
fprintf(fp, '\t\\num{%.4g}', A(i, 1));
for j = 2:n
fprintf(fp, ' & \\num{%.4g}', A(i, j));
end
fprintf(fp, ' \\\\ \n');
end
fprintf(fp, '\\end{%s}', type);
fclose(fp);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment