Matlab code for image analysis, array manipulation and plotting