%-------------------------------------------------------------------------------
% INITIATE CONTROL FIGURE
%-------------------------------------------------------------------------------
global initx;
hFig = findobj( allchild(0), 'Name', 'HSP Control Center' );
% If GUI already exists, bring it to front and escape
if ~isempty(hFig),
set(0,'CurrentFigure',hFig);
return
end
% Time to make a new figure
% Warn user of possible delay
disp('Building HSP Control Interface...')
HspSaveCmdC = ['save hsp_control ',...
'Pn fmin fmax ka touz toup fes1 fes0 kes fesmin fev0 fev1 kev fcs0 ',...
'Gx toux Dx initx'];
%------------------------------------------------------------------------------
% Load Hsp control data -- if not available, Define default parameters
%------------------------------------------------------------------------------
if exist('hsp_control.mat') == 2;
load hsp_control.mat;
else
%display info message
fprintf('\nDefault settings being saved as ''hsp_control.mat...'' \n');
% Initialize variables
%Carotid sinus afferent pathway
Pn=92;
fmin=2.52;
fmax=47.78;
ka=11.758;
touz=6.37;
toup=2.076;
%Sympathetic efferent pathway
fes1=2.10;
fes0=16.11;
kes=0.0675;
fesmin=2.66;
%Vagal efferent pathway
fev0=3.2;
fev1=6.3;
kev=7.06;
fcs0=25;
% Initialize Effector Parameters
%
% Emaxlv Emaxrv Rsp Rep Vusv Vuev Ts Tv
% 1 2 3 4 5 6 7 8
Gx = [0.475 0.282 0.695 0.53 -265.4 -132.5 -0.13 0.09]';
toux = [ 8 8 6 6 20 20 2 1.5 ]';
Dx = [ 2 2 2 2 5 5 2 0.2 ]';
% Initial conditions
initx = [2.392 1.412 2.49 0.78 1435.4 1537 0.58 0]';
% Save Data
save hsp_control Pn fmin fmax ka touz toup ...
fes1 fes0 kes fesmin fev0 fev1 kev fcs0 ...
Gx toux Dx initx
end
load Control
%Main Window
h0 = figure('Color',[0.8 0.8 0.8], ...
'Colormap',mat0, ...
'FileName','D:\MATLAB\work\Control.m', ...
'Name','HSP Control Center', ...
'NumberTitle','off', ...
'PaperPosition',[18 180 576.0000000000001 432.0000000000002], ...
'PaperUnits','points', ...
'Position',[1 1 800 552], ...
'Tag','HspC', ...
'ToolBar','none');
%Title Label
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'FontName','Geneva', ...
'FontSize',20, ...
'FontWeight','bold', ...
'ListboxTop',0, ...
'Position',[57.7241379310345 281.1034482758622 308.4827586206897 39.10344827586208], ...
'String','HSP Control Center', ...
'Style','text', ...
'Tag','StaticText1');
%Save Button
h1 = uicontrol('Parent',h0, ...
'Style', 'pushbutton', ...
'String', 'Save', ...
'Units', 'points', ...
'Position',[422.0689655172415 63.31034482758622 45.31034482758621 19.86206896551725], ...
'Callback', HspSaveCmdC, ...
'Tag', 'SaveBtn');
%Reset Button
h1 = uicontrol('Parent',h0, ...
'Style', 'pushbutton', ...
'String', 'Reset', ...
'Units', 'points', ...
'Position',[423.3103448275863 33.51724137931035 45.31034482758621 19.86206896551725], ...
'Callback', 'delete(gcf); Control;', ... , ...
'Tag', 'ResetBtn');
%Carotid sinus afferent pathway
%Pn
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[19.24137931034483 257.5862068965518 22.96551724137932 12.41379310344828], ...
'String','Pn', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[52.13793103448277 258.2068965517242 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(Pn)'), ...
'Callback','Pn=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
%fmin
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[131.1724137931035 257.5862068965518 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(fmin)'), ...
'Callback','fmin=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[98.20689655172416 257.5862068965518 22.96551724137932 12.41379310344828], ...
'String','fmin', ...
'Style','text', ...
'Tag','StaticText2');
%fmax
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[177.1724137931035 257.5862068965518 22.96551724137932 12.41379310344828], ...
'String','fmax', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[210.1379310344828 257.5862068965518 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(fmax)'), ...
'Callback','fmax=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
%ka
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[289.1034482758621 257.5862068965518 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(ka)'), ...
'Callback','ka=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[256.1379310344828 257.5862068965518 22.96551724137932 12.41379310344828], ...
'String','ka', ...
'Style','text', ...
'Tag','StaticText2');
%touz
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[414.0689655172414 257.5862068965518 22.96551724137932 12.41379310344828], ...
'String','touz', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[447.0344827586207 257.5862068965518 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(touz)'), ...
'Callback','touz=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
%toup
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[335.1034482758621 257.5862068965518 22.96551724137932 12.41379310344828], ...
'String','toup', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[368.0689655172414 257.5862068965518 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(toup)'), ...
'Callback','toup=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
%Sympathetic efferent pathway
%fes1
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',mat1, ...
'String','fes1', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[288.4827586206897 224.6896551724138 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(fes1)'), ...
'Callback','fes1=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
%fes0
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',mat2, ...
'String',eval('num2str(fes0)'), ...
'Callback','fes0=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',mat3, ...
'String','fes0', ...
'Style','text', ...
'Tag','StaticText2');
%kes
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[97.58620689655174 224.6896551724138 22.96551724137932 12.41379310344828], ...
'String','kes', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',mat4, ...
'String',eval('num2str(kes)'), ...
'Callback','kes=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
%fesmin
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[51.58620689655173 224.6896551724138 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(fesmin)'), ...
'Callback','fesmin=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[18.62068965517242 224.6896551724138 22.96551724137932 12.41379310344828], ...
'String','fesmin', ...
'Style','text', ...
'Tag','StaticText2');
%Vagal efferent pathway
%fcs0
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[17.37931034482759 192.4137931034483 22.96551724137932 12.41379310344828], ...
'String','fcs0', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[50.3448275862069 192.4137931034483 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(fcs0)'), ...
'Callback','fcs0=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
%kev
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[129.3103448275862 192.4137931034483 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(kev)'), ...
'Callback','kev=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[96.34482758620692 192.4137931034483 22.96551724137932 12.41379310344828], ...
'String','kev', ...
'Style','text', ...
'Tag','StaticText2');
%fev0
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[175.3103448275862 192.4137931034483 22.96551724137932 12.41379310344828], ...
'String','fev0', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[208.2758620689655 192.4137931034483 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(fev0)'), ...
'Callback','fev0=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
%fev1
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[287.2413793103448 192.4137931034483 36.00000000000001 16.75862068965517], ...
'String',eval('num2str(fev1)'), ...
'Callback','fev1=str2num(get(gcbo, ''String''));', ...
'Style','edit', ...
'Tag','EditText1');
h1 = uicontrol('Parent',h0, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[254.2758620689655 192.4137931034483 22.96551724137932 12.41379310344828], ...
'String','fev1', ...
'Style','text', ...
'Tag','StaticText2');
%-------------------------------------------------------------------------------
% Config figure
%-------------------------------------------------------------------------------
%hFig = figure( ...
% 'Name' , 'Effectors' , ...
% 'Visible' , 'on' , ...
% 'Units' , 'points' , ...
% 'Position' , [5 180 505 275] , ...
% 'numbertitle' , 'off' , ...
% 'Tag' , 'effector' );
%-------------------------------------------------------------------------------
% Set up grid of editable text boxes in the figure
%-------------------------------------------------------------------------------
xCoord = (0:9)*70+5;
yCoord = (0:9)*17+20;
uiWide = 45;
uiHigh = 15;
parts = {'Emax,lv','Emax,rv','Rsp','Rep', ...
'Vu,sv','Vu,ev','T,s','T,v'};
vars = {'Gx','toux','Dx','initx'};
nParts = length(parts);
nVars = length(vars);
etb = zeros( nParts, nVars ); % array for storing editable text box handles
for row = 1:nParts,
% Put in text label for row
txt = uicontrol( ...
'Style' , 'text' , ...
'String' , parts{nParts - row + 1} , ...
'Units' , 'points' , ...
'Position' , [xCoord(1), yCoord(row), uiWide, uiHigh] , ...
'Tag' , 'PartText' );
% Put in an etb for ea. column (ea. variable)
for col = 1:nVars,
% generate variable and callback strings
vText = [ vars{col} '(' num2str(nParts - row + 1) ')' ];
cText = [ vText '=str2num(get(gcbo,''String''));'];
% generate the etb
if row ~= 1 | col ~= 4,
etb(row,col) = uicontrol( ...
'Style' , 'edit' , ...
'String' , eval(['num2str(' vText ')']) , ...
'BackgroundColor', [1 1 1] , ...
'Units' , 'points' , ...
'Position' , [xCoord(col+1) yCoord(row) uiWide uiHigh ], ...
'CallBack' , [cText, 'set_param(gcb,''UserData'',1);'] , ...
'Tag' , [ parts{nParts - row + 1} '_' vars{col} ] );
end
if row == 1,
% put labels on the top of the column
yPreCalc = yCoord(nParts + 1);
txt = uicontrol( ...
'Style' ,'text' , ...
'String' ,vars{col} , ...
'Units' ,'points' , ...
'Position' ,[xCoord(col+1) yPreCalc uiWide uiHigh], ...
'Tag' ,'VarText' );
end % if row =
end % for col =...
end % for row =...