matlab: miscellaneous code for patches management