📄 nefgui.m
字号:
'Style','frame', ...
'Units','normalized', ...
'Position',[0 4*Nspacing+3*NbtnHt 1 3*NbtnHt+0*Nspacing], ...
'BackgroundColor',frmColor);
% create simulate button
simulateb = uicontrol(h, ...
'Style', 'push', ...
'String', 'Simulate', ...
'Interruptible', 'yes', ...
'Units','normalized', ...
'Position', [right-NbtnWid bottom NbtnWid NbtnHt], ...
'CallBack', [...
'global NEFCON_STOP; NEFCON_STOP=0;', ...
'l = get(gcf, ''CurrentObject'');', ...
'set(l,''enable'',''off'');', ...
'nefgui(''simulate'');'],...
'Tag', 'simub');
% create stop button
stopb = uicontrol(h, ...
'Style', 'push', ...
'Interruptible', 'no', ...
'String', 'Stop', ...
'enable', 'off', ...
'Units','normalized', ...
'Position', [right-NbtnWid bottom+NbtnHt+Nspacing NbtnWid NbtnHt], ...
'CallBack', [...
'global NEFCON_STOP; NEFCON_STOP=1;', ...
'l = get(gcf, ''CurrentObject'');', ...
'set(l,''enable'',''off'');'],...
'Tag', 'stopb');
% start/stop time
tmp = uicontrol(h, ...
'Style','text', ...
'BackgroundColor',frmColor, ...
'HorizontalAlignment','left', ...
'Position', [left top-NbtnHt NbtnWid NbtnHt], ...
'Units', 'normalized', ...
'String', 'Start time');
tmp = uicontrol(h, ...
'Style','edit', ...
'BackgroundColor',editColor, ...
'HorizontalAlignment','left', ...
'Position', [left+NbtnWid+Nspacing top-NbtnHt NbtnWid NbtnHt], ...
'Units', 'normalized',...
'CallBack', 'nefgui(''start'')', ...
'String', get_param(NEFCON_SYSNAME,'Start time'), ...
'Tag', 'start');
tmp = uicontrol(h, ...
'Style','text', ...
'BackgroundColor',frmColor, ...
'HorizontalAlignment','left', ...
'Position', [left top-Nspacing-2*NbtnHt NbtnWid NbtnHt], ...
'Units', 'normalized', ...
'String', 'Stop time');
tmp = uicontrol(h, ...
'Style','edit', ...
'BackgroundColor',editColor, ...
'HorizontalAlignment','left', ...
'Position', [left+NbtnWid+Nspacing top-Nspacing-2*NbtnHt NbtnWid NbtnHt], ...
'Units', 'normalized',...
'CallBack', 'nefgui(''stop'')', ...
'String', get_param(NEFCON_SYSNAME,'Stop time'), ...
'Tag', 'stop');
tmp = uicontrol(h, ...
'Style','text', ...
'BackgroundColor',frmColor, ...
'HorizontalAlignment','left', ...
'Position', [left+2*(NbtnWid+Nspacing) top-NbtnHt NbtnWid NbtnHt], ...
'Units', 'normalized', ...
'String', 'Step Size');
tmp = uicontrol(h, ...
'Style','edit', ...
'BackgroundColor',editColor, ...
'HorizontalAlignment','left', ...
'Position', [left+3*(NbtnWid+Nspacing) top-NbtnHt NbtnWid NbtnHt], ...
'Units', 'normalized',...
'CallBack', 'nefgui(''step'')', ...
'String', get_param(NEFCON_SYSNAME,'min step size'), ...
'Tag', 'step');
tmp = uicontrol(h, ...
'Style','text', ...
'BackgroundColor',frmColor, ...
'HorizontalAlignment','left', ...
'Position', [left+2*(NbtnWid+Nspacing) top-Nspacing-2*NbtnHt NbtnWid NbtnHt], ...
'Units', 'normalized', ...
'String', 'Cycles');
tmp = uicontrol(h, ...
'Style','edit', ...
'BackgroundColor',editColor, ...
'HorizontalAlignment','left', ...
'Position', [left+3*(NbtnWid+Nspacing) top-Nspacing-2*NbtnHt NbtnWid NbtnHt], ...
'Units', 'normalized',...
'CallBack', 'nefgui(''cycles'')', ...
'Tag', 'cycles');
% ---------------------------------------------
% nefcon main frame
% ---------------------------------------------
left = Nspacing;
bottom = 3*Nspacing+6*NbtnHt;
width = 1-Nspacing;
height = 1-bottom-Nspacing;
right = left+width;
top = bottom+height;
% The nefcon frame label
labelStr='The NEFCON Model';
statHndl=uicontrol(h, ...
'Style','text', ...
'BackgroundColor',bckfrmColor, ...
'HorizontalAlignment','center', ...
'Position', [left+Nspacing top-NbtnHt width-2*Nspacing NbtnHt], ...
'Units', 'normalized', ...
'String', labelStr);
% ---------------------------------------------
% nefcon graphic
% ---------------------------------------------
ferr = uicontrol(h, 'style','pushbutton',...
'position',[left+NbtnHt top-4*NbtnHt width/3 3*NbtnHt],...
'Units','normalized', ...
'Interruptible','yes', ...
'BackgroundColor',blockColor, ...
'Callback', ...
[ ...
'ferr = get(gcf, ''CurrentObject'');', ...
'set(ferr,''enable'',''off'');', ...
'nefgui_e;',...
'set(ferr,''enable'',''on'');', ...
], ...
'string','Error Definition');
% create connecting arrow
Xstart = left+NbtnHt + width/3;
Xend = left+NbtnHt + width/2;
Ystart = top-2.5*NbtnHt;
Yend = Ystart;
arrow('start', [Xstart Ystart],...
'stop', [Xend Yend], ...
'linewidth', 2, ...
'color', lineColor);
% The Nefcon Learning algor.
left = left + width/2;
lea = uicontrol(h, 'style','pushbutton',...
'position',[left+NbtnHt top-4*NbtnHt width/3 3*NbtnHt],...
'Units','normalized', ...
'Interruptible','yes', ...
'BackgroundColor',blockColor, ...
'Callback', ...
[ ...
'lea = get(gcf, ''CurrentObject'');', ...
'set(lea,''enable'',''off'');', ...
'nefgui_o;',...
'set(lea,''enable'',''on'');', ...
], ...
'string',['Learning Algorithm']);
% create connecting arrow
Xstart = left+NbtnHt + width/6;
Xend = Xstart;
Ystart = top-4*NbtnHt;
Yend = top-height/3-2*NbtnHt;
arrow('start', [Xstart Ystart],...
'stop', [Xend Yend], ...
'linewidth', 3, ...
'color', lineColor, ...
'ends', 3, ...
'length', spacing, ...
'tipangle', 40);
% The Fuzzy Controller
top = top - height/3;
con = uicontrol(h, 'style','pushbutton',...
'position',[left+NbtnHt top-5*NbtnHt width/3 3*NbtnHt],...
'Units','normalized', ...
'Interruptible','no', ...
'BackgroundColor',blockColor, ...
'enable', 'off', ...
'Callback',...
[ ...
'con = get(gcf, ''CurrentObject'');', ...
'set(con,''enable'',''off'');', ...
'global NEFCON_FIS;',...
'if NEFCON_FIS~=[], fuzzy(NEFCON_FIS);',...
'else, nefgui(''status'', ''ERROR: Fismatrix is empty'');',...
'end;',...
'set(con,''enable'',''on'');', ...
], ...
'string','Fuzzy Controller', ...
'tag', 'fuzzyc');
% create connecting arrow
Xstart = left+NbtnHt - width/2 + width/3;
Xend = left+NbtnHt;
Ystart = top-3.5*NbtnHt;
Yend = Ystart;
% input to fuzzy
arrow('start', [Xstart Ystart],...
'stop', [Xend Yend], ...
'linewidth', 2, ...
'color', lineColor);
% input to error
Xstart = Xstart + (Xend-Xstart)*0.5;
Xend = Xstart - (Xend-Xstart)*0.5 - width/5;
Ystart = Ystart;
Yend = top - 4*NbtnHt + height/3;
line([Xstart Xstart Xend],[Ystart Ystart+height*0.18 Ystart+height*0.18], ...
'LineStyle', '-', ...
'LineWidth',2, ...
'Color',lineColor);
arrow('start', [Xend Ystart+height*0.18],...
'stop', [Xend Yend], ...
'linewidth', 2, ...
'color', lineColor);
% create output arrow
Xstart = left+NbtnHt + width/3;
Xend = right;
Ystart = top-3.5*NbtnHt;
Yend = Ystart;
% output
arrow('start', [Xstart Ystart],...
'stop', [Xend Yend], ...
'linewidth', 2, ...
'color', lineColor);
% output to learning
Xstart = Xstart + (Xend-Xstart)*0.5;
Xend = left+NbtnHt + width/3;
Ystart = Ystart;
Yend = top - 2.5*NbtnHt + height/3;
line([Xstart Xstart],[Ystart Yend], ...
'LineStyle', '-', ...
'LineWidth',2, ...
'Color',lineColor);
arrow('start', [Xstart Yend],...
'stop', [Xend Yend], ...
'linewidth', 2, ...
'color', lineColor);
% The Input Preprocessing
left = left - width/2;
inp = uicontrol(h, 'style','pushbutton',...
'position',[left+NbtnHt top-5*NbtnHt width/3 3*NbtnHt],...
'Units','normalized', ...
'Interruptible','yes', ...
'BackgroundColor',blockColor, ...
'Callback', ...
[ ...
'inp = get(gcf, ''CurrentObject'');', ...
'set(inp,''enable'',''off'');', ...
'nefgui_i;',...
'set(inp,''enable'',''on'');', ...
], ...
'string','Input Preprocessing');
tmp = uicontrol(h, ...
'Style','text', ...
'BackgroundColor',blockColor, ...
'HorizontalAlignment','center', ...
'Position', [left+2*NbtnHt top-5*NbtnHt+Nspacing width/3-2*NbtnHt NbtnHt*0.8], ...
'Units', 'normalized', ...
'String', '( 2 inputs )', ...
'tag', 'nofinp');
% input arrow
Xstart = left;
Xend = left+NbtnHt;
Ystart = top - 3.5*NbtnHt;
Yend = Ystart;
arrow('start', [Xstart Ystart],...
'stop', [Xend Yend], ...
'linewidth', 2, ...
'color', lineColor);
% ---------------------------------------------
% variable initilization
% ---------------------------------------------
NEFCON_NOISE=0;
NEFCON_UIH = h;
if NEFCON_STAT == [],
NEFCON_STAT = 0;
end
if NEFCON_STAT == 0
path = [pwd '/'];
fn = [ NEFCON_SYSNAME, '.nef' ];
if exist([path fn])
% ans = questdlg(['Load settings? (' fn ')'],'Yes','No');
ans = 'Yes';
if strcmp(ans, 'Yes')
eval(['load ' [path fn] ' -mat; nefmat(nefsmat);']); % loads matrix smat
nefgui('status', 'INFO: Settings loaded.');
end
end
end
% set actual gain and interval settings and initialize all undefined globals
NEFCON_INT = [];
NEFCON_GAIN = [];
nefdef;
% update display
nefgui('cycles', 'set');
nefgui('nofinp');
nefgui('status');
tagset(NEFCON_UIH, 'status', 'Value', 1);
elseif strcmp(action, 'close'),
% close current nefgui
% matlab dialog error using button...
%ans = questdlg('Save current settings?','Yes','No','Cancel','Yes');
ans = 'Yes';
if strcmp(ans, 'Yes')
path = [pwd '/'];
fn = [ NEFCON_SYSNAME, '.nef' ];
eval(['nefsmat = nefmat; save ' [path fn] ' nefsmat;']);
set(NEFCON_UIH,'visible','off');
% close(gcf);
% NEFCON_UIH = [];
elseif strcmp(ans, 'No')
set(NEFCON_UIH,'visible','off');
% close(gcf);
% NEFCON_UIH = [];
end
elseif strcmp(action, 'status'),
if NEFCON_STAT == [],
NEFCON_STAT = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -