Matlab functions for elasticity sampling