A MATLAB listing, typeset with listings (the matlab-prettifier package gives a closer MATLAB look in a full LaTeX run).
In this preview: the code is shown, not run. To compute with it, open a notebook in MATLAB mode (File, New, Notebook, then choose MATLAB) and paste it there; then copy the results back.
% the eigenvalues of a symmetric matrix
A = [2 -1 0; -1 2 -1; 0 -1 2];
[V, D] = eig(A);
lambda = diag(D)'
x = linspace(0, 2*pi, 100);
plot(x, sin(x)), grid on