Matlab version of python script created