www.gusucode.com > 模糊控制工具箱 fuzzy logic toolbox源码程序 > fuzzy/fuzzy/trndtdlg.m
function trndtdlg(action) %MFDLG Create dialog for generating new fis with data. % MFDLG(action,fisMatrix,varType,varIndex) will open a dialog % box for fisMatrix using the default MF type 'trimf'. % varType and varIndex indicate exactly which variable you % want to add membership functions to. % Kelly Liu 1-2-97 % Copyright 1994-2002 The MathWorks, Inc. % $Revision: 1.8 $ $Date: 2002/04/14 22:22:18 $ if ~isstr(action), % For initialization, the fis matrix is passed in as the parameter oldFigNumber=action; action='#initialize'; end; if strcmp(action,'#initialize'), labelStr='Input Mumber and Output Number'; popupLabel1='MF type'; popupLabel2='Number of MFs'; %=================================== % Information for all objects frmColor=192/255*[1 1 1]; btnColor=192/255*[1 1 1]; popupColor=192/255*[1 1 1]; editColor=255/255*[1 1 1]; border=6; spacing=6; figPos=get(0,'DefaultFigurePosition'); figPos(3:4)=[360 160]; maxRight=figPos(3); maxTop=figPos(4); btnWid=160; btnHt=23; %==================================== % The FIGURE figNumber=figure( ... 'Tag','Input Number and OutPut Number',... 'NumberTitle','off', ... 'Color',[0.9 0.9 0.9], ... 'Visible','off', ... 'MenuBar','none', ... 'Units','pixels', ... 'Position',figPos, ... 'BackingStore','off'); figPos=get(figNumber,'position'); %==================================== % The MAIN frame top=maxTop-border; bottom=border; right=maxRight-border; left=border; frmBorder=spacing; frmPos=[left-frmBorder bottom-frmBorder ... right-left+frmBorder*2 top-bottom+frmBorder*2]+[1 1 1 1]; mainFrmHndl=uicontrol( ... 'Style','frame', ... 'Units','pixel', ... 'Position',frmPos, ... 'BackgroundColor',frmColor); %==================================== % The UPPER frame top=maxTop-spacing-border; bottom=border+8*spacing+3*btnHt; right=maxRight-border-spacing; left=border+spacing; frmBorder=spacing; frmPos=[left-frmBorder bottom-frmBorder ... right-left+frmBorder*2 top-bottom+frmBorder*2]+[1 0 1 0]; varFrmHndl=uicontrol( ... 'Units','pixel', ... 'Style','frame', ... 'Position',frmPos, ... 'BackgroundColor',frmColor); varSpacing=(top-bottom-2*btnHt); %------------------------------------ % The STRING text field n=1; labelStr=labelStr; pos=[left top-btnHt*n-varSpacing*(n-1) right-left btnHt]; uicontrol( ... 'Units','pixel', ... 'Style','text', ... 'BackgroundColor',frmColor, ... 'HorizontalAlignment','left', ... 'Position',pos, ... 'String',labelStr); %==================================== % The POPUP frame bottom=border+4*spacing+btnHt; top=bottom+2*btnHt+spacing; right=maxRight-border-spacing; left=border+spacing; frmBorder=spacing; frmPos=[left-frmBorder bottom-frmBorder ... right-left+frmBorder*2 top-bottom+frmBorder*2]+[1 0 1 0]; topFrmHndl=uicontrol( ... 'Style','frame', ... 'Units','pixel', ... 'Position',frmPos, ... 'BackgroundColor',frmColor); %------------------------------------ % The POPUP text field labelStr='input Number'; pos=[left top-btnHt btnWid-spacing btnHt]; uicontrol( ... 'Units','pixel', ... 'Style','text', ... 'HorizontalAlignment','left', ... 'Position',pos, ... 'BackgroundColor','white', ... 'String',labelStr,... 'Tag', 'inputNumtxt'); uicontrol( ... 'Units','pixel', ... 'Style','edit', ... 'HorizontalAlignment','left', ... 'Position',pos+[btnWid 0 0 0], ... 'BackgroundColor','white', ... 'String','2',... 'Tag', 'inputNum'); %------------------------------------ % The POPUP text field labelStr='Output Number'; pos=[left top-2*btnHt-spacing btnWid-spacing btnHt]; uicontrol( ... 'Units','pixel', ... 'Style','text', ... 'HorizontalAlignment','left', ... 'Position',pos, ... 'BackgroundColor','white', ... 'String',labelStr,... 'Tag', 'outputNumtxt'); uicontrol( ... 'Units','pixel', ... 'Style','edit', ... 'HorizontalAlignment','left', ... 'Position',pos+[btnWid 0 0 0], ... 'BackgroundColor','white', ... 'String','1',... 'Tag', 'outputNum'); %==================================== % The CLOSE frame bottom=border+spacing; top=bottom+btnHt; right=maxRight-border-spacing; left=border+spacing; frmBorder=spacing; frmPos=[left-frmBorder bottom-frmBorder ... right-left+frmBorder*2 top-bottom+frmBorder*2]+[1 0 1 0]; clsFrmHndl=uicontrol( ... 'Style','frame', ... 'Units','pixel', ... 'Position',frmPos, ... 'BackgroundColor',frmColor); %------------------------------------ % The CANCEL button labelStr='Cancel'; callbackStr='close(gcf)'; infoHndl=uicontrol( ... 'Style','push', ... 'Position',[left bottom btnWid btnHt], ... 'BackgroundColor',btnColor, ... 'String',labelStr, ... 'Callback',callbackStr); %------------------------------------ % The OKAY button labelStr='OK'; callbackStr='trndtdlg #okay'; closeHndl=uicontrol( ... 'Style','push', ... 'Position',[right-btnWid bottom btnWid btnHt], ... 'BackgroundColor',btnColor, ... 'String',labelStr, ... 'UserData',oldFigNumber, ... 'Callback',callbackStr); % Normalize all coordinates hndlList=findobj(figNumber,'Units','pixels'); set(hndlList,'Units','normalized'); % Uncover the figure set(figNumber, ... 'Visible','on'); elseif strcmp(action,'#okay'), figNumber=gcf; oldFigNumber=get(gco,'UserData'); inHndl=findobj(figNumber,'Tag','inputNum'); outHndl=findobj(figNumber,'Tag','outputNum'); fis.inNum=str2double(get(inHndl, 'String')); fis.outNum=str2double(get(outHndl, 'String')); set(oldFigNumber,'Userdata', fis); close(figNumber); figure(oldFigNumber); end