Demonstration code in Matlab