misc scripts and functions in matlab