some matlab scripts and functions