\documentclass{article}

\usepackage{listings}


 \usepackage{xepersian}


\begin{document}

 \begin{LTR} % comment this line if you have removed xepersian
\lstset{
language=Matlab,
frame=trBL, 
 basicstyle=\footnotesize\ttfamily,
  keywordstyle=\bfseries\ttfamily, 
}  



% Default Computer Modern font (no bold implemented)
\renewcommand{\ttdefault}{cmtt}
\begin{lstlisting}
   for j=1:e+1
          plot(z(1,1:e+1),n(1,1:e+1),'g')
   if x<= 5
\end{lstlisting}

% Using Courier font
\renewcommand{\ttdefault}{pcr}
\begin{lstlisting}
   for j=1:e+1
          plot(z(1,1:e+1),n(1,1:e+1),'g')
   if x<= 5
 \end{lstlisting}

 \end{LTR}  % comment this line if you have removed xepersian
\end{document}