fix bug in matlab code related to partial contacts