Please don't forget to pre-allocate the loop variables
According to your GUI and given input conditions, line(i)==6 and line(i) ==3 these condition are not met. You already defined Button_press = 0 but not e_rewarded. just for an e.g. when you define your variable e_rewarded to some value/random array it will not throws any error.
But when you run the same code I think you mean what you have written in pushbutton1_Callback, still MATLAB throws the following error:
Undefined function or variable 'e_rewarded'
Are you sure that your m.file works fine even without defining variable e_rewarded?
Could you please attached it too ?