I wanted to include a m-file which has very long lines, too long to display in a single line in my document. After reading the listings user reference I found how to do this:
\lsinputlisting[breaklines=true]{file.m}
you can also show only a few lines, for example only line 4 to 15 of the file.m file: