function invGUI() 

%**************************************************************%
%This functions creates a graphical user interface which       %
%contains an animation of the inverted pendulum control        %
%experiment.  This function was created for the Control        %    
%Tutorials for Matlab. It requires the functions invFUN.m and  %
%invODE.m to be executed.                                      %           
%                                                              %
%Copyright (C) 1997 by the Regents of the University of        %
%Michigan.                                                     %
%**************************************************************%                     

a = figure('Color',[1 1 1], ...
	'Position',[300 150 675 675], ...
	'Tag','Fig1');
whitebg
whitebg

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[0 0 0], ...
	'Position',[0.1526 0.7393 0.2311 0.2044], ...
	'Style','frame', ...
	'Tag','Nbarframe');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.1615 0.7496 0.2133 0.1853], ...
	'Style','frame', ...
	'Tag','Kframe');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 0 0], ...
	'Callback','invFUN(1)', ...
	'Position',[0.21037 0.85037 0.111111 0.0459259], ...
	'String','RUN', ...
	'Tag','Runbutton');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 0], ...
	'Callback','invFUN(2)', ...
	'Position',[0.275556 0.785185 0.082963 0.0459259], ...
	'String','RESET', ...
	'Tag','clear');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[0 1 0], ...
	'Callback','invFUN(4)', ...
	'Position',[0.176296 0.785185 0.0844444 0.0459259], ...
	'String','REPEAT', ...
	'Tag','repbutton');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[0 0 0], ...
	'Position',[0.151111 0.554074 0.24 0.148148], ...
	'Style','frame', ...
	'Tag','cartframe');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.16 0.562963 0.222222 0.128889], ...
	'Style','frame', ...
	'Tag','pendframe');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.177778 0.645926 0.185185 0.0311111], ...
	'String','Weighing Factor', ...
	'Style','text', ...
	'Tag','xytitle');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.214815 0.619259 0.0192593 0.0281481], ...
	'String','x', ...
	'Style','text', ...
	'Tag','staticxtext');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.293333 0.619259 0.0503704 0.0281481], ...
	'String','theta', ...
	'Style','text', ...
	'Tag','staticytext');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.188148 0.582222 0.0740741 0.037037], ...
	'String','50', ...
	'Style','edit', ...
	'Tag','xtext', ...
	'Value',1);

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.28 0.582222 0.0740741 0.037037], ...
	'String','100', ...
	'Style','edit', ...
	'Tag','ytext', ...
	'Value',1);

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[0 0 0], ...
	'Position',[0.136296 0.377778 0.268148 0.139259], ...
	'Style','frame', ...
	'Tag','timeframe');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.145185 0.386667 0.25037 0.12], ...
	'Style','frame', ...
	'Tag','sliin');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Callback','invFUN(3)', ...
	'Max',0.5, ...
	'Min',-0.5, ...
	'Position',[0.205926 0.414815 0.13037 0.0281481], ...
	'Style','slider', ...
	'Tag','stepslider', ...
	'Value',0.2);

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.151111 0.420741 0.0459259 0.0177778], ...
	'String','-0.5', ...
	'Style','text', ...
	'Tag','slid_min');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.336296 0.420741 0.0459259 0.0177778], ...
	'String',' 0.5', ...
	'Style','text', ...
	'Tag','slid_max');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.177778 0.460741 0.102222 0.0281481], ...
	'String','Step Input:', ...
	'Style','text', ...
	'Tag','step_text');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.271111 0.460741 0.102222 0.0281481], ...
	'String','0.2000', ...
	'Style','text', ...
	'Tag','curtext');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[0 0 0], ...
	'Position',[0.131852 0.0918519 0.278519 0.256296], ...
	'Style','frame', ...
	'Tag','stepframe');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.140741 0.282963 0.259259 0.0533333], ...
	'String','Manual Advance', ...
	'Style','checkbox', ...
	'Tag','manualbox');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.140741 0.222222 0.259259 0.0533333], ...
	'String','Plot Separately', ...
	'Style','checkbox', ...
	'Tag','plotbox');

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.140741 0.162963 0.259259 0.0533333], ...
	'String','Reference Input', ...
	'Style','checkbox', ...
	'Tag','reference', ...
	'Value',1);

b = uicontrol('Parent',a, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[0.140741 0.102222 0.259259 0.0533333], ...
	'String','Non-Linear System', ...
	'Style','checkbox', ...
	'Tag','syscheckbox');

b = axes('Parent',a, ...
	'Box','on', ...
	'Color',[1 1 1], ...
	'Position',[0.577977 0.581098 0.327023 0.343902], ...
	'Tag','Axes1', ...
	'XColor',[0 0 0], ...
	'YColor',[0 0 0]);

c = text('Parent',b, ...
	'Color',[0 0 0], ...
	'HorizontalAlignment','center', ...
	'Position',[0.5 1.03247 0], ...
	'String','Cart Position & Pendulum Angle Over Time', ...
	'Tag','Text2', ...
	'VerticalAlignment','bottom');
set(get(c,'Parent'),'Title',c);

c = text('Parent',b, ...
	'Color',[0 0 0], ...
	'HorizontalAlignment','center', ...
	'Position',[0.5 -0.0844156 0], ...
	'String','Time (sec.)', ...
	'Tag','Text5', ...
	'VerticalAlignment','cap');
set(get(c,'Parent'),'XLabel',c);

c = text('Parent',b, ...
	'Color',[0 0 0], ...
	'HorizontalAlignment','center', ...
	'Position',[-0.121005 0.5 0], ...
	'Rotation',90, ...
	'Tag','Text6', ...
	'VerticalAlignment','baseline');
set(get(c,'Parent'),'YLabel',c);

b = axes('Parent',a, ...
	'Box','on', ...
	'Color',[1 1 1], ...
	'Position',[0.577977 0.11 0.327023 0.343902], ...
	'Tag','Axes2', ...
	'XColor',[0 0 0], ...
	'XLim',[-0.7 0.7], ...
	'YColor',[0 0 0], ...
	'YLim',[-0.1 0.9]);

c = text('Parent',b, ...
	'Color',[0 0 0], ...
	'HorizontalAlignment','center', ...
	'Position',[-2.22045e-16 0.932468 0], ...
	'String','Inverted Pendulum Animation', ...
	'Tag','Text3', ...
	'VerticalAlignment','bottom');
set(get(c,'Parent'),'Title',c);

c = text('Parent',b, ...
	'Color',[0 0 0], ...
	'HorizontalAlignment','center', ...
	'Position',[-2.22045e-16 -0.184416 0], ...
	'String','X Position (m)', ...
	'Tag','Text4', ...
	'VerticalAlignment','cap');
set(get(c,'Parent'),'XLabel',c);

c = text('Parent',b, ...
	'Color',[0 0 0], ...
	'HorizontalAlignment','center', ...
	'Position',[-0.920548 0.4 0], ...
	'Rotation',90, ...
	'String','Y Position (m)', ...
	'Tag','Text8', ...
	'VerticalAlignment','baseline');
set(get(c,'Parent'),'YLabel',c);
