Modified matlab code for better interaction with user.