If I compile the next code the following error appear.
! Package inputenc Error: Unicode char \u8:�\expandafter\lst@FillFixed@\fi not set up for use with LaTeX.
See the inputenc package documentation for explanation. Type H for immediate help. ...
l.6 ...%% sI A tiene inversa esta es la soluci�n( Vector Nulo) ?
Then when I comment "\usepackage[utf8]{inputenc}" the code compile, but I need the utf8 package. How could I fix it?
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage{float}
\usepackage{verbatim}
\usepackage{listings}
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}
\usepackage{hyperref}
\usepackage{txfonts,pxfonts}
\begin{document}
\section*{Matlab Code}
\begin{lstlisting}
clc, clear
syms k1 k2 y m
A= [0 1 0 1;-1*(k1+k2)/m 0 k2/m 0; 0 0 0 1; k2/m 0 0 -(k1+k2)/m];
cero=zeros(4);
determinante=det(A); %% Determinante de A
Sol=A\cero;%% sI A tiene inversa esta es la solución(Vector Nulo)
% El unico punto de equilibrio es el punto 0
detervalprop= det(A-y*eye(4))
[V,D]=eig(A)
f=subs(D(1),m,1)
%figure
%ezsurf(f)
%figure
%subplot(2,1,2)
h=ezplot(f)
set(h, 'Color', 'r')
\end{lstlisting}
\end{document}


\lstinputlistingit cannot help on the use of thelstlistingenv like you use here. – daleif May 31 '16 at 17:58\lstinputlistingbecause thelistingsutf8should work, do remember to read the manual for that package. Generally I don't recommend to include the source code directly into the tex code, as you can very easily forget to update it. Much better to keep it external such that the code you include is the same that you use for what ever it is you are doing. – daleif May 31 '16 at 18:13