bug fixes, more error checking and code cleanup

added more error checks for user inputs
fixed some bugs
added plotting of raw data
replaced global variables with guidata structure
commented code