⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 surfview.m

📁 模糊逻辑工具箱 模糊逻辑工具箱 模糊逻辑工具箱 模糊逻辑工具箱 模糊逻辑工具箱
💻 M
📖 第 1 页 / 共 2 页
字号:
function surfview(action);
%SURFVIEW Output surface viewer.
%   The Surface Viewer displays the entire output surface 
%   for one output variable and two input variables. More 
%   than two inputs and one output can be accomodated by using 
%   the popup menus just below the plot region.             
%                                                 
%   If there are more than two inputs for a given system, 
%   reference input values must be supplied for the non-varying
%   inputs. This is done using the Ref. Input text field.         
%                                                  
%   A wide variety of plotting and display options are available 
%   from the Options menu.          
%                                                  
%   See Also 
%       fuzzy, mfedit, ruleedit, ruleview, anfisedit, gensurf

%   Ned Gulley, 3-30-94, Kelly Liu 7-20-96
%   Copyright (c) 1994-98 by The MathWorks, Inc.
%   $Revision: 1.39 $  $Date: 1997/12/01 21:45:57 $

if nargin<1,
    % Open up an untitled system.
    newFis=newfis('Untitled');
    newFis=addvar(newFis,'input','input1',[0 1]);
    newFis=addvar(newFis,'output','output1',[0 1]);
    action=newFis;
end

if isstr(action),
    if action(1)~='#',
        % The string "action" is not a switch for this function, 
        % so it must be a disk file
        fis=readfis(action);
        action='#initialize';
    end
else
    % For initialization, the fis matrix is passed in as the parameter
    fis=action;
    action='#initialize';
end;

if strcmp(action,'#initialize'),
    %====================================
    fisName=fis.name;
    % Set up default colormap
    colorMap=jet(150);
    colorMap=colorMap(33:97,:);
    nameStr=['Surface Viewer: ' fisName];
    thisfis{1}=fis;
    figNumber=figure( ...
        'Name',nameStr, ...
        'NumberTitle','off', ...
        'Visible','off', ...
        'MenuBar','none', ...
        'UserData',thisfis, ...
        'Tag','surfview', ...
        'Renderer', 'zbuffer', ...
        'DefaultAxesFontSize',8, ...
        'ColorMap',colorMap);
    figPos=get(figNumber,'position');

    %====================================
    % The MENUBAR items
    % First create the menus standard to every GUI
    fisgui #initialize
 
    editHndl=findobj(figNumber,'Type','uimenu','Tag','editmenu');
        uimenu(editHndl,'Label','Undo', ...
            'Enable','off');

    labelStr=menulabel('&Options ');
    optHndl=uimenu(figNumber, ...
        'Label',labelStr, ...
        'Tag','optionsmenu');
        plotHndl=uimenu(optHndl, ...
            'Label','Plot', ...
            'Tag','plottype');
            callbackStr='surfview #plotselect';
            uimenu(plotHndl,'Label','Surface', ...
                'Checked','on', ...
                'Callback',callbackStr);
            uimenu(plotHndl,'Label','Lit Surface', ...
                'Checked','off', ...
                'Callback',callbackStr);
            uimenu(plotHndl,'Label','Mesh', ...
                'Checked','off', ...
                'Callback',callbackStr);
            uimenu(plotHndl,'Label','X Mesh', ...
                'Checked','off', ...
                'Callback',callbackStr);
            uimenu(plotHndl,'Label','Y Mesh', ...
                'Checked','off', ...
                'Callback',callbackStr);
            uimenu(plotHndl,'Label','Contour', ...
                'Checked','off', ...
                'Callback',callbackStr);
            uimenu(plotHndl,'Label','Pseudo-Color', ...
                'Checked','off', ...
                'Callback',callbackStr);
            uimenu(plotHndl,'Label','Quiver', ...
                'Checked','off', ...
                'Callback',callbackStr);
        mapHndl=uimenu(optHndl,'Label','Color Map','Tag','colormap');
            uimenu(mapHndl,'Label','Default', ...
                'Callback','surfview #colormap');
            uimenu(mapHndl,'Label','Blue', ...
                'Callback','surfview #colormap');
            uimenu(mapHndl,'Label','Hot', ...
                'Callback','surfview #colormap');
            uimenu(mapHndl,'Label','HSV', ...
                'Callback','surfview #colormap');
        uimenu(optHndl,'Label','Always evaluate', ...
            'Separator','on', ...
            'Checked','on', ...
            'Tag','alwayseval', ...
            'Callback','surfview #evaltoggle');

    %===================================
    % 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];
    axColor=128/255*[1 1 1];
    border=6;
    spacing=6;
    maxRight=figPos(3);
    maxTop=figPos(4);
    btnWid=90;
    btnHt=22;

    bottom=border;
    top=bottom+4*btnHt+9*spacing;
    right=maxRight-border;
    left=border;
 
    %====================================
    % The MAIN frame
    frmBorder=spacing;
    frmPos=[left-frmBorder bottom-frmBorder ...
        right-left+frmBorder*2 top-bottom+frmBorder*2];
    frmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...
        'BackgroundColor',frmColor);

    %====================================
    % The AXIS
    axBorder=40;
    axPos=[left+3*axBorder top+axBorder right-left-6.5*axBorder ...
        maxTop-top-border-1.5*axBorder];
    axHndl=axes( ...
        'Units','pixel', ...
        'Position',axPos, ...
        'NextPlot','replace', ...
        'Box','on');
    titleStr=['Output surface for the FIS ' fisName];
    title(titleStr);

    %====================================
    % The DATA frame 
    top=top-spacing;
    bottom=top-spacing-2*btnHt;
    right=maxRight-border-spacing;
    left=border+spacing;
    frmBorder=spacing;
    frmPos=[left-frmBorder bottom-frmBorder ...
        right-left+frmBorder*2 top-bottom+frmBorder*2];
    dataFrmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...
        'BackgroundColor',frmColor);

    dtBtnWid=0.95*btnWid;
    dtBtnWidWide=1.1*dtBtnWid;
    dtBtnWidNarrow=2*dtBtnWid-dtBtnWidWide;
    dtSpacing=(right-left-6*dtBtnWid)/5;
    %------------------------------------
    % The X-AXIS text field
    n=1;
    labelStr='X (input):';
    pos=[left+(n-1)*(dtBtnWid+dtSpacing) top-btnHt dtBtnWidNarrow btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor',frmColor', ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'String',labelStr);

    %------------------------------------
    % The X-AXIS popup menu
    n=2;
    name='xaxis';
    callbackStr='surfview #xaxis';
    pos=[left+(n-2)*(dtBtnWid+dtSpacing)+dtBtnWidNarrow+dtSpacing ...
        top-btnHt dtBtnWidWide btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','popupmenu', ...
        'BackgroundColor',popupColor, ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'Callback',callbackStr, ...
        'String', ' ', ...
        'Tag',name);

    %------------------------------------
    % The Y-AXIS text field
    n=3;
    labelStr='Y (input):';
    pos=[left+(n-1)*(dtBtnWid+dtSpacing) top-btnHt dtBtnWidNarrow btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor',frmColor', ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'String',labelStr);

    %------------------------------------
    % The Y-AXIS popup menu
    n=4;
    name='yaxis';
    callbackStr='surfview #yaxis';
    pos=[left+(n-2)*(dtBtnWid+dtSpacing)+dtBtnWidNarrow+dtSpacing ...
        top-btnHt dtBtnWidWide btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','popupmenu', ...
        'BackgroundColor',popupColor, ...
        'HorizontalAlignment','left', ...
        'Callback',callbackStr, ...
        'Units','pixel', ...
        'Position',pos, ...
        'String', ' ', ...
        'Tag',name);

    %------------------------------------
    % The Z-AXIS text field
    n=5;
    labelStr='Z (output):';
    pos=[left+(n-1)*(dtBtnWid+dtSpacing) top-btnHt dtBtnWidNarrow btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor',frmColor', ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'String',labelStr);

    %------------------------------------
    % The Z-AXIS popup menu
    n=6;
    name='zaxis';
    callbackStr='surfview #refinputedit';
    pos=[left+(n-2)*(dtBtnWid+dtSpacing)+dtBtnWidNarrow+dtSpacing ...
        top-btnHt dtBtnWidWide btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','popupmenu', ...
        'BackgroundColor',popupColor, ...
        'HorizontalAlignment','left', ...
        'Callback',callbackStr, ...
        'Units','pixel', ...
        'Position',pos, ...
        'String', ' ', ...
        'Tag',name);

    %------------------------------------
    % The X-GRID text field
    n=1;
    labelStr='X grids:';
    pos=[left+(n-1)*(dtBtnWid+dtSpacing) top-2*btnHt-spacing dtBtnWidNarrow btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor',frmColor', ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'String',labelStr);

    %------------------------------------
    % The X-GRID edit field
    n=2;
    labelStr=' 15';
    name='xgrid';
    callbackStr='surfview #grids';
    pos=[left+(n-2)*(dtBtnWid+dtSpacing)+dtBtnWidNarrow+dtSpacing ...
        top-2*btnHt-spacing dtBtnWidWide btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','edit', ...
        'BackgroundColor',editColor, ...
        'HorizontalAlignment','left', ...
        'Callback',callbackStr, ...
        'Units','pixel', ...
        'Position',pos, ...
        'Tag',name, ...
        'String',labelStr);

    %------------------------------------
    % The Y-GRID text field
    n=3;
    labelStr='Y grids:';
    pos=[left+(n-1)*(dtBtnWid+dtSpacing) top-2*btnHt-spacing dtBtnWidNarrow btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor',frmColor', ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'String',labelStr);

    %------------------------------------
    % The Y-GRID edit field
    n=4;
    labelStr=' 15';
    name='ygrid';
    callbackStr='surfview #grids';
    pos=[left+(n-2)*(dtBtnWid+dtSpacing)+dtBtnWidNarrow+dtSpacing ...
        top-2*btnHt-spacing dtBtnWidWide btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','edit', ...
        'BackgroundColor',editColor, ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'Callback',callbackStr, ...
        'Tag',name, ...
        'String',labelStr);

    %------------------------------------
    % The EVALUATE button
    n=6;
    labelStr='Evaluate';
    name='evaluate';
    callbackStr='surfview #evaluate';
    pos=[left+(n-2)*(dtBtnWid+dtSpacing)+dtBtnWidNarrow+dtSpacing ...
        top-2*btnHt-spacing dtBtnWidWide btnHt];
    ruleDispHndl=uicontrol( ...
        'Style','pushbutton', ...
        'BackgroundColor',btnColor, ...
        'Units','pixel', ...
        'Position',pos, ...
        'Callback',callbackStr, ...
        'Enable','off', ...
        'Tag',name, ...
        'String',labelStr);

    %====================================
    % The REFERENCE INPUT frame 
    bottom=border+4*spacing+btnHt;
    top=bottom+btnHt;
    left=border+spacing;
    right=maxRight-border-2*btnWid-5*spacing;

    frmBorder=spacing;
    frmPos=[left-frmBorder bottom-frmBorder ...
        right-left+frmBorder*2 top-bottom+frmBorder*2];
    topFrmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...
        'BackgroundColor',frmColor);

    refSpacing=(right-left-3*btnWid)/2;
    %------------------------------------
    % The REFERENCE INPUT text window
    labelStr='Ref. Input:';
    pos=[left bottom btnWid btnHt];
    helpHndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor',frmColor', ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'String',labelStr);

    %------------------------------------
    % The INPUT edit window
    name='refinputedit';
    callbackStr='surfview #refinputedit';
    pos=[left+btnWid+spacing bottom right-left-btnWid-spacing btnHt];
    inputDispHndl=uicontrol( ...
        'Style','edit', ...
        'BackgroundColor',editColor, ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'Tag',name, ...
        'Callback',callbackStr);

    %====================================
    % The CLOSE frame 
    right=maxRight-border-spacing;
    left=right-2*btnWid-spacing;
    frmBorder=spacing;
    frmPos=[left-frmBorder bottom-frmBorder ...
        right-left+frmBorder*2 top-bottom+frmBorder*2];
    clsFrmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...
        'BackgroundColor',frmColor);

    %------------------------------------
    % The HELP button
    labelStr='Help';
    callbackStr='surfview #help';
    helpHndl=uicontrol( ...
        'Style','push', ...
        'Position',[left bottom btnWid btnHt], ...
        'BackgroundColor',btnColor, ...
        'String',labelStr, ...
        'Callback',callbackStr);

    %------------------------------------
    % The CLOSE button
    labelStr='Close';
    callbackStr='fisgui #close';
    closeHndl=uicontrol( ...
        'Style','push', ...
        'Position',[right-btnWid bottom btnWid btnHt], ...
        'BackgroundColor',btnColor, ...
        'String',labelStr, ...
        'Callback',callbackStr);

    %====================================
    % The STATUS 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];
    dataFrmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -