Skip to content

Instantly share code, notes, and snippets.

@mattdee123
Created October 27, 2014 04:14
Show Gist options
  • Save mattdee123/5bad6938d4edeae1abb3 to your computer and use it in GitHub Desktop.
Save mattdee123/5bad6938d4edeae1abb3 to your computer and use it in GitHub Desktop.
function s = tex(m)
s = '\bm ';
for r = 1:size(m,1)
for c =1:size(m,2)
delim = '&';
if (c == size(m,2))
delim = '';
end
s = [s, K.asStr(m(r,c)), delim];
end
if r ~= size(m,1)
s = strcat(s, '\\');
end
end
s = strcat(s,'\em');
s = strrep(s,'sin','\sin');
s = strrep(s,'cos','\cos');
s = regexprep(s, 'cos\((\w*)\)', 'cos $1');
s = regexprep(s, 'sin\((\w*)\)', 'sin $1');
end
@mattdee123
Copy link
Author

function s = asStr(x)
if strcmp(class(x),'sym')
s = char(x);
else
s = num2str(x)
end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment