if you want to do it by yourself in Matlab, I think it would be helpful to have a look at the Fortran code developed by David M. Boore. Here is the webpage of Dr. Boore .http://www.daveboore.com/
you can find all his publications and software he developed in seismology on his web page..
You can also have a look at the files of SHAKE software which is used for linear and equivalent non-linear site effects.