handle old matlab without 'datasample' function problem