In the MWE below, the text (fonts and colors) from the Matlab Code read from \lstinputlisting do not show up like that from the Matlab generated from the lstlisting code:
\documentclass{book}
\usepackage[svgnames]{xcolor}
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{avant}
\usepackage{mathptmx}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{filecontents}
\begin{filecontents*}{sample.m}
% create a file for output
!touch testFile.txt
fid = fopen('testFile.text', 'w')
for i=1:10
fprintf(fid,'%6.2f \n', i);
end
\end{filecontents*}
\usepackage[numbered,framed]{matlab-prettifier}
\usepackage[font={color=ocre,bf},figurename=Fig.,labelfont={it}]{caption}
\newfontfamily{\lstconsolas}{Consolas}
\newcommand\ph\mlplaceholder
\begin{document}
\lstlistoflistings
\lstinputlisting[caption=Sample code from Matlab]{sample.m}
\begin{lstlisting}[
style=Matlab-editor,
basicstyle=\lstconsolas,
escapechar=`,
caption={For educational purposes},
]
% example of while loop using placeholders
while x2 = 1 + 100`\ph{condition}`
if `\ph{something-bad-happens}`
break
else
% do something useful
end
% do more things
end
\end{lstlisting}
\end{document}
how can I get both the sample.m file code (the code read from the Matlab file) to show up with the colors and boxes and line numbers?
Also, how do you change the size of the Matlab code fonts?

style=Matlab-editor... the font size can be changed as part of thebasicstylekey, for examplebasicstyle=\lstconsolas\small,. – Paul Gessler Jun 08 '15 at 23:08