Matlab-version of particle filter