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

📄 surfview.m

📁 模糊控制工具箱,很好用的,有相应的说明文件,希望对大家有用!
💻 M
📖 第 1 页 / 共 2 页
字号:
function surfview(action);
%SURFVIEW Output surface viewer.
%   The Surface Viewer invoked using surfview('a') is a GUI tool that lets you 
%   examine the output surface of a FIS, a.fis, for any one or two inputs. 
%   Since it does not alter the fuzzy system or its associated FIS matrix in 
%   any way, it is a read-only editor. Using the pop-up menus, you select the 
%   two input variables you want assigned to the two input axes (X and Y), as 
%   well the output variable you want assigned to the output (or Z) axis. Select 
%   the Evaluate button to perform the calculation and plot the output surface.
%   By clicking on the plot axes and dragging the mouse, you can actually 
%   manipulate the surface so that you can view it from different angles.
%   If there are more than two inputs to your system, you must supply, in the 
%   reference input section, the constant values associated with any unspecified 
%   inputs. 
%   
%   See also ANFISEDIT, FUZZY, GENSURF, MFEDIT, RULEEDIT, RULEVIEW

%   Ned Gulley, 3-30-94, Kelly Liu 7-20-96, N. Hickey 03-17-01
%   Copyright 1994-2004 The MathWorks, Inc.
%   $Revision: 1.49.2.2 $  $Date: 2004/04/10 23:15:39 $

if nargin<1,
    % Open up an untitled system.
    newFis=newfis('Untitled');
    newFis=addvar(newFis,'input','input1',[0 1],'init');
    newFis=addvar(newFis,'output','output1',[0 1],'init');
    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', ...
        'IntegerHandle','off',...
        'MenuBar','none', ...
        'UserData',thisfis, ...
        'Tag','surfview', ...
        'Renderer', 'zbuffer', ...
        'DefaultAxesFontSize',8, ...
        'ColorMap',colorMap, ...
        'DockControls', 'off');
    figPos=get(figNumber,'position');

    %====================================
    % The MENUBAR items
    % Call fisgui to create the menubar items
    fisgui #initialize
 
    %===================================
    % 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, ...
        'BackgroundColor',frmColor);

    %------------------------------------
    % The STATUS text window
    labelStr='Status info go here';
    name='status';
    pos=[left bottom right-left btnHt];
    hndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor',frmColor', ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'Tag',name, ...
        'String',labelStr);

    surfview #update
    rotate3d on

    % Normalize all coordinates
    hndlList=findobj(figNumber,'Units','pixels');
    set(hndlList,'Units','normalized');
 
    % Uncover the figure
    set(figNumber, ...
        'Visible','on');

elseif strcmp(action,'#update');
    %====================================
    figNumber=watchon;
    oldfis=get(figNumber,'UserData');

⌨️ 快捷键说明

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