Code covered by the BSD License  

Highlights from
Controls Tutor

image thumbnail

Controls Tutor

by

 

Help understand the fundamentals of classical control theory.

contutor
function contutor
% CONTUTOR The Controls Tutor Environment.
%          CONTUTOR is the main function which invokes the Controls Tutor.

% Author: Craig Borghesani
% Date: 8/7/94
% Revised: 10/17/94, 12/7/94
% Copyright (c) 1999, Prentice-Hall

% test for version
%mat_ver = version;
%mat_ver = mat_ver(1:3);
%if (~strcmp(mat_ver,'5.0')) & (~strcmp(mat_ver,'Stu')),
% error('The Controls Tutor requires 4.2 or later OR Student Edition.');
%end

if ~exist('rlocus'),
 error('Required: The Control Systems Toolbox OR Student Edition of MATLAB');
end

% define various shades of grey
grey = get(0,'defaultuicontrolbackground');
ltgrey = [0.5,0.5,0.5]*1.5;
dkgrey = [0.5,0.5,0.5]*0.5;

% setup main environment window
scrn_size = get(0,'screensize');
oth_win = get(0,'chil');
win_ct = 1;
for k = 1:length(oth_win),
 oth_name = get(oth_win(k),'name');
 if length(oth_name) > 13,
  if strcmp(oth_name(1:14),'Controls Tutor'),
   win_ct = win_ct + 1;
  end
 end
end
name_str = 'Controls Tutor - [Untitled]';
win_str = '';
if win_ct > 1,
 win_str = [':',int2str(win_ct)];
end
name_str = [name_str,win_str];

%fig_lft = scrn_size(3)*0.015; fig_btm = scrn_size(4)*0.07;
menu_bar = scrn_size(4)*0.0833;
%fig_wdt = scrn_size(3)-fig_lft*2;
%fig_hih = scrn_size(4)-menu_bar*2;
fig_wdt = 780;
fig_hih = 500;
fig_lft = (scrn_size(3) - fig_wdt)/2;
fig_btm = (scrn_size(4) - (fig_hih+40))/2;
main_figr = figure('pos',[fig_lft,fig_btm,fig_wdt,fig_hih],'numbertitle','off',...
                   'name',name_str,'resize','off','menubar','none',...
                   'interruptible','on',...
                   'windowbuttondownfcn','pagemous',...
                   'paperorientation','landscape',...
                   'paperposition',[0.75,1.125,9.5,6.25],...
                   'color',[0.8,0.8,0.8],...
                   'defaultaxescolor','w',...
                   'defaultaxesxcolor','k',...
                   'defaultaxesycolor','k',...
                   'defaulttextcolor','k',...
                   'vis','off',...
                   'tag','contutor');

frm_lft = 2; frm_wdt = 145; frm_hih = 163;
frm_btm = fig_hih - 13 - frm_hih;
axs_lft = (frm_wdt+frm_lft+60)/fig_wdt;
axs_wdt = 0.97 - axs_lft;
fontname = 'times';

% status bar
%'pos',[axs_lft*fig_wdt,0,(fig_wdt-axs_lft*fig_wdt),15],...
stat_bar = uicontrol('style','edit',...
                     'pos',[0,0,fig_wdt,20],...
                     'backgroundcolor',grey,'foregroundcolor','k',...
                     'horizontalalignment','left',...
                     'enable','inactive');
set(stat_bar,'string','Setting up user interface...');

% File menu
file_menu(1) = uimenu('label','File');
file_menu(2) = uimenu(file_menu(1),'label','New',...
                   'callback','fileoptn(7);');
file_menu(3) = uimenu(file_menu(1),'label','Open...',...
                   'callback','fileoptn(8);');
file_menu(4) = uimenu(file_menu(1),'label','Save',...
                   'callback','fileoptn(3);');
file_menu(5) = uimenu(file_menu(1),'label','Save As...',...
                   'callback','fileoptn(4);');
file_menu(6) = uimenu(file_menu(1),'label','In from Workspace...','separator','on',...
                   'callback','infrmwks(0)','vis','off');
file_menu(7) = uimenu(file_menu(1),'label','Out to Workspace...',...
                   'callback','outtowks(0)','vis','off');
file_menu(8) = uimenu(file_menu(1),'label','Print','separator','on',...
                   'callback','fileoptn(5);');
file_menu(9) = uimenu(file_menu(1),'label','Record','vis','off');
file_menu(10) = uimenu(file_menu(1),'label','Playback','vis','off');
file_menu(11) = uimenu(file_menu(1),'label','Exit','separator','on',...
                   'callback','fileoptn(9);');

% Options menu
options_menu(1) = uimenu('label','Options');
options_menu(2) = uimenu(options_menu(1),'label','Show All Systems',...
               'callback','pageplot(0,12)');
options_menu(3) = uimenu(options_menu(1),'label','System 1',...
               'callback','dispfrac(1)','checked','on');
options_menu(4) = uimenu(options_menu(1),'label','System 2',...
               'callback','dispfrac(2)');
options_menu(5) = uimenu(options_menu(1),'label','System 3',...
               'callback','dispfrac(3)');
options_menu(6) = uimenu(options_menu(1),'label','Show All','separator','on',...
               'callback','pageplot(0,12)');
options_menu(7) = uimenu(options_menu(1),'label','Plant, P(s)','separator','on',...
               'callback','dispfrac(4)','checked','on');
options_menu(8) = uimenu(options_menu(1),'label','Forward Controller, G(s)',...
               'callback','dispfrac(5)');
options_menu(9) = uimenu(options_menu(1),'label','Feedback Controller, H(s)',...
               'callback','dispfrac(6)');
options_menu(10) = uimenu(options_menu(1),'label','','separator','on',...
               'callback','termimpl(15,0,0)');
options_menu(11) = uimenu(options_menu(1),'label','',...
               'callback','termimpl(15,0,0)');
set(options_menu(3:9),'vis','off');

options_menu(12) = uimenu(options_menu(1),'label','Controller Type','separator','on',...
               'enable','off');
options_menu(13) = uimenu(options_menu(12),'label','Num-Den','checked','on',...
               'callback','pidimpl(0,3)');
options_menu(14) = uimenu(options_menu(12),'label','PID (form 1)',...
               'callback','pidimpl(0,4)');
options_menu(15) = uimenu(options_menu(12),'label','PID (form 2)',...
               'callback','pidimpl(0,5)');
options_menu(16) = uimenu(options_menu(12),'label','PID (form 3)',...
               'callback','','vis','off');
options_menu(17) = uimenu(options_menu(1),'label','Num-Den','vis','off');
options_menu(18) = uimenu(options_menu(1),'label','State-Space','vis','off');
options_menu(19) = uimenu(options_menu(1),'label','Discrete','vis','off');

% Display menu
disp_menu(1) = uimenu('label','Format');
disp_menu(2) = uimenu(disp_menu(1),'label','Individual','checked','on',...
               'callback','dispfrac(7)');
disp_menu(3) = uimenu(disp_menu(1),'label','Open-Loop',...
               'callback','dispfrac(8)');
disp_menu(4) = uimenu(disp_menu(1),'label','Closed-Loop',...
               'callback','dispfrac(9)');
disp_menu(5) = uimenu(disp_menu(1),'label','Factored','separator','on',...
               'checked','on','callback','dispfrac(10)');
disp_menu(6) = uimenu(disp_menu(1),'label','Polynomial',...
               'callback','dispfrac(11)');
disp_menu(7) = uimenu(disp_menu(1),'label','Inverse Laplace',...
               'callback','dispfrac(12)');

% View menu
view_menu(1) = uimenu('label','View');
view_menu(2) = uimenu(view_menu(1),'label','Full','callback','pageview(1)');
view_menu(3) = uimenu(view_menu(1),'label','In','callback','pageview(2)');
view_menu(4) = uimenu(view_menu(1),'label','Out','callback','pageview(3)');
view_menu(5) = uimenu(view_menu(1),'label','Zoom','callback','pageview(4)');
view_menu(6) = uimenu(view_menu(1),'label','Last','callback','pageview(5)');
axisset_menu = uimenu(view_menu(1),'label','Limits...','separator','on',...
               'callback','axisset(1)');
view_menu(7) = uimenu(view_menu(1),'label','Grid','separator','on',...
               'callback','pageview(6)');
view_menu(8) = uimenu(view_menu(1),'label','Page Layout...','separator','on',...
                   'callback','pagesetu');

% Tools menu
tools_menu(1) = uimenu('label','Tools');
tools_menu(2) = uimenu(tools_menu(1),'label','Frequency Response');

% Bode/Nichols/Nyquist Tools
tools_menu(3) = uimenu(tools_menu(2),'label','Open-Loop','checked','on',...
                    'callback','pageplot(1,1)');
tools_menu(4) = uimenu(tools_menu(2),'label','Closed-Loop',...
                    'callback','pageplot(1,2)');
tools_menu(5) = uimenu(tools_menu(2),'label','Exact','checked','on',...
                    'separator','on','callback','pageplot(1,3)');
tools_menu(6) = uimenu(tools_menu(2),'label','Straight-Line',...
                    'callback','pageplot(1,4)');
tools_menu(7) = uimenu(tools_menu(2),'label','Margins',...
                    'callback','pageplot(1,5)');
tools_menu(8) = uimenu(tools_menu(2),'label','Frequency...','separator','on',...
                    'callback','vectedit(0,1)');

% Root Locus Tools
tools_menu(9) = uimenu(tools_menu(1),'label','Root Locus');
tools_menu(10) = uimenu(tools_menu(9),'label','Positive Locus',...
                    'callback','pageplot(2,1)','checked','on');
tools_menu(11) = uimenu(tools_menu(9),'label','Negative Locus',...
                    'callback','pageplot(2,2)');
tools_menu(12) = uimenu(tools_menu(9),'label','Real Axis Loci','separator','on',...
                    'callback','pageplot(2,3)');
tools_menu(13) = uimenu(tools_menu(9),'label','Asymptotes',...
                    'callback','pageplot(2,4)');
tools_menu(14) = uimenu(tools_menu(9),'label','BreakAway-Reentry',...
                    'callback','pageplot(2,5)');
tools_menu(15) = uimenu(tools_menu(9),'label','Imaginary Axis Crossing',...
                    'callback','pageplot(2,6)');
tools_menu(16) = uimenu(tools_menu(9),'label','Arrival-Departure',...
                    'callback','pageplot(2,7)');
tools_menu(17) = uimenu(tools_menu(9),'label','Root Locus',...
                    'callback','pageplot(2,8)');
tools_menu(18) = uimenu(tools_menu(9),'label','Closed-Loop Poles',...
                    'callback','pageplot(2,9)');
tools_menu(19) = uimenu(tools_menu(9),'label','Gain...','separator','on',...
                    'callback','vectedit(0,2)');

% Time Response Tools
tools_menu(20) = uimenu(tools_menu(1),'label','Time Response');
tools_menu(21) = uimenu(tools_menu(20),'label','Open-Loop',...
                    'callback','pageplot(3,1)','checked','on');
tools_menu(22) = uimenu(tools_menu(20),'label','Closed-Loop',...
                    'callback','pageplot(3,2)');
tools_menu(23) = uimenu(tools_menu(20),'label','Unit Impulse',...
                    'callback','pageplot(3,3)','separator','on');
tools_menu(24) = uimenu(tools_menu(20),'label','Unit Step',...
                    'callback','pageplot(3,4)','checked','on');
tools_menu(25) = uimenu(tools_menu(20),'label','Unit Ramp',...
                    'callback','pageplot(3,5)');
tools_menu(26) = uimenu(tools_menu(20),'label','Rise Time','separator','on',...
                    'callback','pageplot(3,6)');
tools_menu(27) = uimenu(tools_menu(20),'label','Delay Time',...
                    'callback','pageplot(3,7)');
tools_menu(28) = uimenu(tools_menu(20),'label','Peak Time',...
                    'callback','pageplot(3,8)');
tools_menu(29) = uimenu(tools_menu(20),'label','% Overshoot',...
                    'callback','pageplot(3,9)');
tools_menu(30) = uimenu(tools_menu(20),'label','2% Settling',...
                    'callback','pageplot(3,10)');
tools_menu(31) = uimenu(tools_menu(20),'label','5% Settling',...
                    'callback','pageplot(3,11)');
tools_menu(32) = uimenu(tools_menu(20),'label','Time...','separator','on',...
                    'callback','vectedit(0,3)');

set(tools_menu,'vis','off');

page_menu = uimenu('label','Page');
help_menu = uimenu('label','Help');
uimenu(help_menu,'label','Tutor Help','callback','userhelp(0)');
uimenu(help_menu,'label','About...','separator','on',...
         'callback','fileoptn(23)');

drawnow;

% USER INTERFACE SETUP
uicontrol('style','frame','pos',[frm_lft,frm_btm,frm_wdt,frm_hih],'vis','off');
lab_txt(1) = uicontrol('style','push','pos',[8,frm_btm+frm_hih-9,133,20],...
                       'callback','dispfrac(5)','vis','off');

% Add control
ui_han(1)=uicontrol('style','popup','pos',[4,frm_btm+126,140,20],...
  'string',['Gain|Integrator|Differentiator|Real Pole|Real Zero|',...
            'Complex Pole|Complex Zero|Lead/Lag|Num/Den|Delay Time|Design Point'],...
  'callback','termmang(0,1,1)','backgroundcolor','w','vis','off');

% Text display
ui_han(2)=uicontrol('style','text','pos',[4,frm_btm+99,46,17],...
          'horizontalalignment','right','vis','off');
ui_han(3)=uicontrol('style','text','pos',[4,frm_btm+52,46,17],...
          'horizontalalignment','right','vis','off');

% Edit controls
ui_han(4)=uicontrol('style','edit','pos',[52,frm_btm+99,90,17],...
          'backgroundcolor','w','vis','off');
ui_han(5)=uicontrol('style','edit','pos',[52,frm_btm+52,90,17],...
          'backgroundcolor','w','vis','off');

% Iterate controls
ui_han(6) = uicontrol('style','slider','pos',[4,frm_btm+79,141,15],'vis','off');
ui_han(7) = uicontrol('style','slider','pos',[4,frm_btm+32,141,15],'vis','off');

% Add/Update button
ui_han(8)=uicontrol('style','push','pos',[4,frm_btm+2,60,20],'vis','off');

% Delete button
ui_han(9)=uicontrol('style','push','pos',[85,frm_btm+2,60,20],'string','Delete','vis','off');

% Transfer Function display axes
ui_han(10) = axes('pos',[0.05,0.88,1-axs_lft,0.12],...
            'xlim',[0,1],'ylim',[0,1],'vis','off',...
            'drawmode','fast','nextplot','add','vis','off',...
            'defaulttextcolor','k');

% Mouse Location
lab_txt(2) = uicontrol('style','push','pos',[8,frm_btm-22,133,20],'vis','off');

ui_han(11) = axes('pos',[8,frm_btm-80,frm_wdt,58]./[fig_wdt,fig_hih,fig_wdt,fig_hih],...
            'drawmode','fast','nextplot','add','vis','off');

% determine appropriate size of font for monitor
test_str = 'M';
font_size = 5;
txt_bot = 1;
txt = text(0,1,test_str,'fontsize',font_size,'vis','off','fontname',fontname,...
           'verticalalignment','top');
while txt_bot > 0,
 font_size = font_size + 1;
 set(txt,'fontsize',font_size);
 txt_ext = get(txt,'extent');
 txt_bot = txt_ext(2)-3*(txt_ext(4)-0.03);
end
font_size = font_size - 1;

% System Info
lab_txt(3) = uicontrol('style','push','pos',[8,frm_btm-107,133,20],...
                       'callback','dispfrac(2)','vis','off');

ui_han(12) = axes('pos',[8,2,frm_wdt,frm_btm-109]./[fig_wdt,fig_hih,fig_wdt,fig_hih],...
            'drawmode','fast','nextplot','add','vis','off');

lft = fig_wdt - 190;
btm = fig_hih - 22;
frame1_pos = [lft-5,fig_hih-315,190,293];

% setup tabular options
ui_obj.SysTabs(1) = uicontrol('style','push',...
                      'pos',[lft,btm-2,60,20],...
                      'string','System 1',...
                      'back',grey,...
                      'enable','inactive',...
                      'buttondownfcn','dispfrac(1)');
ui_obj.SysTabs(2) = uicontrol('style','push',...
                      'pos',[lft+60,btm-2,60,20],...
                      'string','System 2',...
                      'back',ltgrey,...
                      'enable','inactive',...
                      'buttondownfcn','dispfrac(2)');
ui_obj.SysTabs(3) = uicontrol('style','push',...
                      'pos',[lft+120,btm-2,60,20],...
                      'string','System 3',...
                      'back',ltgrey,...
                      'enable','inactive',...
                      'buttondownfcn','dispfrac(3)');

ui_obj.frame1 = uicontrol('style','push',...
                      'pos',frame1_pos,...
                      'back',grey,...
                      'fore',grey,...
                      'enable','off');

ui_obj.eraser1 = uicontrol('style','text');

btm = btm - 25;
uicontrol('style','text',...
          'pos',[lft,btm,50,17],...
          'string','Block',...
          'horiz','left',...
          'back',grey);
ui_obj.SysUI(1) = uicontrol('style','radio',...
                      'pos',[lft+60,btm,40,20],...
                      'string','P(s)',...
                      'back',grey,...
                      'value',1,...
                      'callback','dispfrac(4)');
ui_obj.SysUI(2) = uicontrol('style','radio',...
                      'pos',[lft+100,btm,40,20],...
                      'string','G(s)',...
                      'back',grey,...
                      'callback','dispfrac(5)');
ui_obj.SysUI(3) = uicontrol('style','radio',...
                      'pos',[lft+140,btm,40,20],...
                      'string','H(s)',...
                      'back',grey,...
                      'callback','dispfrac(6)');

btm = btm - 25;
ui_obj.SysUI(4) = uicontrol('style','text',...
                            'pos',[lft,btm,60,17],...
                            'string','Element',...
                            'horiz','left',...
                            'back',grey);
ui_obj.SysUI(5) = uicontrol('style','popup',...
                            'pos',[lft+60,btm,120,20],...
                            'string',['Gain|Integrator|Differentiator|Real Pole|Real Zero|',...
                                      'Complex Pole|Complex Zero|Lead/Lag|Num/Den|Delay Time|Design Point'],...
                            'callback','termmang(0,1,1)','backgroundcolor','w');

btm = btm - 25;
ui_obj.SysUI(6) = uicontrol('style','text',...
                      'pos',[lft,btm,60,17],...
                      'string','Gain',...
                      'back',grey,...
                      'horiz','left');
ui_obj.SysUI(7) = uicontrol('style','edit',...
                      'pos',[lft+60,btm,110,20],...
                      'horiz','right',...
                      'back','w');
ui_obj.SysUI(8) = uicontrol('style','slider',...
                      'pos',[lft+170,btm,10,20],...
                      'min',0,'max',0.1,...
                      'userdata',ui_obj.SysUI(7));
set(ui_obj.SysUI(7),'userdata',ui_obj.SysUI(8));

btm = btm - 25;
ui_obj.SysUI(9) = uicontrol('style','text',...
                      'pos',[lft,btm,60,17],...
                      'string','',...
                      'back',grey,...
                      'horiz','left');
ui_obj.SysUI(10) = uicontrol('style','edit',...
                      'pos',[lft+60,btm,110,20],...
                      'horiz','right',...
                      'back','w');
ui_obj.SysUI(11) = uicontrol('style','slider',...
                      'pos',[lft+170,btm,10,20],...
                      'min',0,'max',0.1,...
                      'userdata',ui_obj.SysUI(10));
set(ui_obj.SysUI(10),'userdata',ui_obj.SysUI(11));

btm = btm - 25;
ui_obj.SysUI(12) = uicontrol('style','push',...
                      'pos',[lft,btm,87.5,20],...
                      'string','Add',...
                      'back',grey);
ui_obj.SysUI(13) = uicontrol('style','push',...
                      'pos',[lft+92.5,btm,87.5,20],...
                      'string','Delete',...
                      'back',grey);

btm = btm - 22;
ui_obj.SysUI(14) = uicontrol('style','text',...
                      'pos',[lft,btm,180,17],...
                      'string','System Info',...
                      'horiz','left',...
                      'back',grey);
ui_obj.SysUI(15) = uicontrol('style','listbox',...
                      'pos',[lft,btm-60,180,60],...
                      'back','w');

btm = btm - 82;
ui_obj.SysUI(16) = uicontrol('style','text',...
                      'pos',[lft,btm,180,17],...
                      'string','Plot Info',...
                      'horiz','left',...
                      'back',grey);
ui_obj.SysUI(17) = uicontrol('style','edit',...
                      'pos',[lft,btm-60,180,60],...
                      'back','w','max',2,...
                      'horiz','left',...
                      'enable','inactive');

btm = fig_hih - 337;
frame2_pos = [lft-5,fig_hih-478,190,141];

% setup tabular options
ui_obj.ToolTabs(1) = uicontrol('style','push',...
                      'pos',[lft,btm-2,60,20],...
                      'string','Freq',...
                      'back',grey,...
                      'enable','inactive',...
                      'buttondownfcn','cttools(''Freq'')');
ui_obj.ToolTabs(2) = uicontrol('style','push',...
                      'pos',[lft+60,btm-2,60,20],...
                      'string','Root',...
                      'back',ltgrey,...
                      'enable','inactive',...
                      'buttondownfcn','cttools(''Root'')');
ui_obj.ToolTabs(3) = uicontrol('style','push',...
                      'pos',[lft+120,btm-2,60,20],...
                      'string','Time',...
                      'back',ltgrey,...
                      'enable','inactive',...
                      'buttondownfcn','cttools(''Time'')');

ui_obj.frame2 = uicontrol('style','push',...
                      'pos',frame2_pos,...
                      'back',grey,...
                      'fore',grey,...
                      'enable','off');

ui_obj.eraser2 = uicontrol('style','text');

% Frequency tools
btm = fig_hih - 360;
ui_obj.FreqUI(1) = uicontrol('style','check',...
                      'pos',[lft,btm,85,20],...
                      'string','Open-Loop',...
                      'value',1,...
                      'callback','pageplot(1,1)');
ui_obj.FreqUI(2) = uicontrol('style','check',...
                      'pos',[lft+90,btm,85,20],...
                      'string','Closed-Loop',...
                      'callback','pageplot(1,2)');

btm = btm - 25;
ui_obj.FreqUI(3) = uicontrol('style','check',...
                      'pos',[lft,btm,150,20],...
                      'string','Exact',...
                      'value',1,...
                      'callback','pageplot(1,3)');
btm = btm - 20;
ui_obj.FreqUI(4) = uicontrol('style','check',...
                      'pos',[lft,btm,150,20],...
                      'string','Straight-Line',...
                    'callback','pageplot(1,4)');
btm = btm - 20;
ui_obj.FreqUI(5) = uicontrol('style','check',...
                      'pos',[lft,btm,150,20],...
                      'string','Margins',...
                      'callback','pageplot(1,5)');

btm = btm - 25;
ui_obj.FreqUI(6) = uicontrol('style','push',...
                      'pos',[lft,27,180,20],...
                      'string','Frequency...',...
                      'callback','vectedit(0,1)');

% Root Locus tools
btm = fig_hih - 360;
ui_obj.RootUI(1) = uicontrol('style','radio',...
                      'pos',[lft,btm,85,20],...
                      'string','Pos. Locus',...
                      'value',1,...
                      'callback','pageplot(2,1)');
ui_obj.RootUI(2) = uicontrol('style','radio',...
                      'pos',[lft+90,btm,85,20],...
                      'string','Neg. Locus',...
                      'callback','pageplot(2,2)');
btm = btm - 25;
ui_obj.RootUI(3) = uicontrol('style','check',...
                      'pos',[lft,btm,85,20],...
                      'string','Real Loci',...
                      'callback','pageplot(2,3)');
ui_obj.RootUI(4) = uicontrol('style','check',...
                      'pos',[lft+90,btm,85,20],...
                      'string','Asymptotes',...
                      'callback','pageplot(2,4)');
btm = btm - 20;
ui_obj.RootUI(5) = uicontrol('style','check',...
                      'pos',[lft,btm,85,20],...
                      'string','BreakAway',...
                      'callback','pageplot(2,5)');
ui_obj.RootUI(6) = uicontrol('style','check',...
                      'pos',[lft+90,btm,85,20],...
                      'string','Imag. Cross.',...
                      'callback','pageplot(2,6)');
btm = btm - 20;
ui_obj.RootUI(7) = uicontrol('style','check',...
                      'pos',[lft,btm,85,20],...
                      'string','Arrival-Depart',...
                      'callback','pageplot(2,7)');
ui_obj.RootUI(8) = uicontrol('style','check',...
                      'pos',[lft+90,btm,85,20],...
                      'string','Root Locus',...
                      'callback','pageplot(2,8)');
btm = btm - 20;
ui_obj.RootUI(9) = uicontrol('style','check',...
                      'pos',[lft,btm,180,20],...
                      'string','Closed-Loop Poles',...
                      'callback','pageplot(2,9)');

btm = btm - 25;
ui_obj.RootUI(10) = uicontrol('style','push',...
                      'pos',[lft,27,180,20],...
                      'string','Gain...',...
                      'callback','vectedit(0,2)');

% Time tools
btm = fig_hih - 360;
ui_obj.TimeUI(1) = uicontrol('style','check',...
                      'pos',[lft,btm,85,20],...
                      'string','Open-Loop',...
                      'value',1,...
                      'callback','pageplot(3,1)');
ui_obj.TimeUI(2) = uicontrol('style','check',...
                      'pos',[lft+90,btm,85,20],...
                      'string','Closed-Loop',...
                      'callback','pageplot(3,2)');
btm = btm - 25;
ui_obj.TimeUI(3) = uicontrol('style','check',...
                      'pos',[lft,btm,60,20],...
                      'string','Impulse',...
                      'callback','pageplot(3,3)');
ui_obj.TimeUI(4) = uicontrol('style','check',...
                      'pos',[lft+65,btm,60,20],...
                      'string','Step',...
                      'value',1,...
                      'callback','pageplot(3,4)');
ui_obj.TimeUI(5) = uicontrol('style','check',...
                      'pos',[lft+130,btm,50,20],...
                      'string','Ramp',...
                      'callback','pageplot(3,5)');
btm = btm - 25;
ui_obj.TimeUI(6) = uicontrol('style','check',...
                      'pos',[lft,btm,85,20],...
                      'string','Rise Time',...
                      'callback','pageplot(3,6)');
ui_obj.TimeUI(7) = uicontrol('style','check',...
                      'pos',[lft+90,btm,85,20],...
                      'string','Delay Time',...
                      'callback','pageplot(3,7)');
btm = btm - 20;
ui_obj.TimeUI(8) = uicontrol('style','check',...
                      'pos',[lft,btm,85,20],...
                      'string','Peak Time',...
                      'callback','pageplot(3,8)');
ui_obj.TimeUI(9) = uicontrol('style','check',...
                      'pos',[lft+90,btm,85,20],...
                      'string','% Overshoot',...
                      'callback','pageplot(3,9)');
btm = btm - 20;
ui_obj.TimeUI(10) = uicontrol('style','check',...
                      'pos',[lft,btm,85,20],...
                      'string','2% Settling',...
                      'callback','pageplot(3,10)');
ui_obj.TimeUI(11) = uicontrol('style','check',...
                      'pos',[lft+90,btm,85,20],...
                      'string','5% Settling',...
                      'callback','pageplot(3,11)');

btm = btm - 25;
ui_obj.TimeUI(12) = uicontrol('style','push',...
                      'pos',[lft,27,180,20],...
                      'string','Time...',...
                      'callback','vectedit(0,3)');

page_setup = [1,  2,  4,  5,  6,  8,  0,  0;
              0,  3,  0,  0,  7,  0,  0,  0;
              0,  0,  0,  0,  0,  0,  0,  0;
              0,  0,  0,  0,  0,  0,  0,  0];

sys_state = [1,  1,  1;
             0,  0,  0;
             0,  0,  0;
             0,  0,  0;
             0,  0,  0;
             1,  1,  1;
             0,  0,  0;
             0,  0,  0;
             1,  1,  1;
             0,  0,  0;
             0,  0,  0];

plant1_mat = [1,0,NaN,1;0,NaN,NaN,2];
pid1_mat = [1,0,0,20];

w = logspace(-2,3,100);
plant1_res = [w;ones(2,length(w))];

ui_han = [ui_han,file_menu,options_menu,disp_menu,view_menu,tools_menu,...
          page_menu,help_menu,axisset_menu];

% system responses
set(ui_han(1:3),'userdata',plant1_res);

% plant and controller initial matrices
set(ui_han(4:18),'userdata',plant1_mat);
set(ui_han(19:24),'userdata',pid1_mat);

% current system
set(ui_han(30),'userdata',1);

% current page
set(ui_han(31),'userdata',[]);

% system state storage
set(ui_han(33),'userdata',sys_state);

% page setup
set(ui_han(34),'userdata',page_setup);

% default time vector
set(ui_han(40),'userdata',linspace(0,5,100));

% check version of controls toolbox
%set(ui_han(41),'userdata',1);
%if ~exist('ngrid') & (~strcmp(mat_ver,'Stu')),
% set(ui_han(39),'userdata',logspace(-2,3,50));
% set(ui_han(41),'userdata',0);
%end

set(ui_han(42),'userdata',font_size);
set(ui_han(43),'userdata',stat_bar);
set(ui_han(44),'userdata',lab_txt);
set(ui_han(45),'userdata','Untitled');
set(ui_han(47),'userdata',0);
set(ui_han(48),'userdata',win_str);

set(main_figr,'userdata',{ui_han, ui_obj});
set(stat_bar,'string','Setting up page layout...');

cttools('Freq');

pagelayo

pagesele(-1)

dispfrac(-1)

set(stat_bar,'string','Welcome to the Controls Tutor');
drawnow;
set(main_figr,'vis','on');

Contact us