I have a matlab code and I want explain part of them like picture. or any other idea can do better.
\documentclass{article}
\usepackage{listings}
\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\begin{document}
\lstset{language=Matlab,%
%basicstyle=\color{red},
breaklines=true,%
morekeywords={matlab2tikz},
keywordstyle=\color{blue},%
morekeywords=[2]{1}, keywordstyle=[2]{\color{black}},
identifierstyle=\color{black},%
stringstyle=\color{mylilas},
commentstyle=\color{mygreen},%
showstringspaces=false,%without this there will be a symbol in the places where there is a space
numbers=left,%
numberstyle={\tiny \color{black}},% size of the numbers
numbersep=9pt, % this defines how far the numbers are from the text
emph=[1]{for,end,break},emphstyle=[1]\color{red}, %some words to emphasise
%emph=[2]{word1,word2}, emphstyle=[2]{style},
}
\section*{Matlab Code}
\lstinputlisting{WEIGHT.m}
\end{document}
WEIGHT.m matlab file
clc
clear all
n=input('Please Enter Number Of Grid Point n=');
%-------------
x=zeros(n,1);A=zeros(n,n);
%-------------
for i=1:n
x(i)=0.5*(1-cos((i-1)*pi/(n-1)));
end
for i=1:n
for j=1:n
Pi=1;Pj=1;
for m=1:n
if m~=i
Pi=(x(i)-x(m))*Pi;
end
if m~=j
Pj=(x(j)-x(m))*Pj;
end
end
if i~=j
A(i,j)=Pi/((x(i)-x(j))*Pj);
end
end
for m=1:n
if m~=i
A(i,i)=A(i,i)-A(i,m);
end
end
end


matlab-prettifierpackage; see this answer. – jub0bs Sep 30 '15 at 09:46