function varargout = updategui(varargin)

%create a run time object that can return the value of the gain block's
%output and then put the value in a string.
rto = get_param('mytestmdl/Gain','RuntimeObject');
str = num2str(rto.OutputPort(1).Data);
out_num=rto.OutputPort(1).Data;

%get a handle to the GUI's 'current state' window
statestxt = findobj('Tag','curState');

%update the gui
set(statestxt,'string',str);

load clown 
handles.I1 = X;
handles.cmap1 = map;

load mandrill
handles.I2 = X;
handles.cmap2 = map;

handles.axes1=findobj('Tag','axes1')

control = evalin('base','control');

if(out_num<0)
    control
    if (control==0)
        control=1;
        assignin('base','control',control);
        axes(handles.axes1);
    end
    dbstop if error
    image(handles.I1); colormap(handles.cmap1)   
else
    control
    if (control==0)
        control=1;
        assignin('base','control',control);
        axes(handles.axes1); 
    end
    image(handles.I2); colormap(handles.cmap2) 
 end


