Matlab code - single instance