Useful matlab tools and function