adding matlab code for snapshot