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

📄 ruleview.m

📁 最新模糊逻辑工具箱
💻 M
📖 第 1 页 / 共 4 页
字号:
function ruleview(action, input, figNumber);
%RULEVIEW Rule viewer and fuzzy inference diagram.
%   RULEVIEW(FIS) opens the Rule Viewer, or Inference Diagram
%   Viewer, for the fuzzy inference system associated with
%   the matrix FIS. RULEVIEW('FILENAME') will search the MATLAB
%   path and open the system FILENAME.FIS if it finds it.
%
%   The Rule Viewer displays, in one screen, all parts of 
%   the fuzzy inference process from inputs to outputs. Each 
%   row of plots corresponds to one rule, and each column of 
%   plots corresponds to either an input variable (yellow, on 
%   the left) or an output variable (blue, on the right). You
%   can change the system input either by typing a specific 
%   value into the Input window or by moving the long yellow 
%   index lines that go down each input variable's column of 
%   plots.
%                                                      
%   The aggregate membership function for each output variable 
%   is shown in the bottom right along with the defuzzified 
%   output value.                         
%                                                      
%   See also 
%       fuzzy, mfedit, ruleedit, surfview, anfisedit

%   Ned Gulley, 3-30-94 Kelly Liu 4-20-97
%   Copyright (c) 1994-98 by The MathWorks, Inc.
%   $Revision: 1.49 $  $Date: 1997/12/05 18:21:21 $

inputColor=[1 0 0];
outputColor=[0 0 1];

if nargin<1,
    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;
    numRules=length(fis.rule);
    thisfis{1}=fis;
    figNumber=figure( ...
        'Name',['Rule Viewer: ' fisName], ...
        'NumberTitle','off', ...
        'MenuBar','none', ...
        'Visible','off', ...
        'UserData',thisfis, ...
        'Tag','ruleview', ...
        'Color',[.9 .9 .9], ...
        'DoubleBuffer', 'on', ...
        'BackingStore','off');
    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');
        formatHndl=uimenu(optHndl,'Label','Rule display format', ...
            'Tag','dispformat');
            callbackStr='ruleview #dispformat';
            uimenu(formatHndl,'Label','Verbose', ...
                'Checked','on', ...
                'Tag','verbose', ...
                'Callback',callbackStr);
            uimenu(formatHndl,'Label','Symbolic', ...
                'Checked','off', ...
                'Tag','symbolic', ...
                'Callback',callbackStr);
            uimenu(formatHndl,'Label','Indexed', ...
                'Checked','off', ...
                'Tag','indexed', ...
                'Callback',callbackStr);

    %===================================
    % 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;
    maxRight=figPos(3);
    maxTop=figPos(4);
    btnWid=90;
    btnHt=22;

    bottom=border;
    top=bottom+2*btnHt+5*spacing;
    right=maxRight-border;
    left=border;
 
    %====================================
    % The MAIN frame
    % This frame is given a name so that it can be located later on
    % using "findobj". The UserData for this frame will contain the
    % matrix of line handles used in the callbacks.
    name='dataframe';
    frmBorder=spacing;
    frmPos=[left-frmBorder bottom-frmBorder ...
        right-left+frmBorder*2 top-bottom+frmBorder*2]+[1 0 1 0];
    frmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...
        'Tag',name, ...
        'BackgroundColor',frmColor);

    %====================================
    % The INPUT frame 
    top=top-spacing;
    bottom=top-btnHt;
    left=border+spacing;
    right=maxRight-border-1.5*btnWid-5*spacing;
    frmBorder=spacing;
    frmPos=[left-frmBorder bottom-frmBorder ...
        right-left-1.75*btnWid top-bottom+frmBorder*2]+[1 0 1 0];
    topFrmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...
        'BackgroundColor',frmColor);
    %-------numPts----------------------
    frmPos=[right-frmBorder-1.75*btnWid+.5*spacing bottom-frmBorder ...
        1.25*btnWid+1.5*spacing top-bottom+frmBorder*2]+[1 0 1 0];
    topFrmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...
        'BackgroundColor',frmColor);

    %------------------------------------
    % The num of points text window
    labelStr='Plot points:';
    pos1=[right-frmBorder-1.75*btnWid+spacing*1 bottom .78*btnWid btnHt];
    helpHndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor', frmColor, ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos1, ...
        'String',labelStr);
    %------------------------------------
    % The INPUT text window
    labelStr='Input:';
    pos=[left-spacing*.5 bottom btnWid/2 btnHt];
    helpHndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor',frmColor, ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'String',labelStr);

    %------------------------------------
    % The INPUT edit window
    callbackStr='ruleview #updateinputs';
    name='inputdisp';
    pos=[left+btnWid/2-2*spacing bottom right-left-btnWid*2.25 btnHt];
    inputDispHndl=uicontrol( ...
        'Style','edit', ...
        'BackgroundColor',editColor, ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'Tag',name, ...
        'Callback',callbackStr);
    %------------------------------------
    % The #points edit window
    name='numdisp';
    pos=[right-frmBorder-.85*btnWid-spacing*1 bottom .5*btnWid btnHt];
%pos1+[btnWid*.4 0 0 0];
    inputDispHndl=uicontrol( ...
        'Style','edit', ...
        'BackgroundColor',editColor, ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos, ...
        'Callback', 'ruleview #update',...
        'Tag',name);

    %====================================
    % The CLOSE/HELP 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]+[1 0 1 0];
    clsFrmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...
        'BackgroundColor',frmColor);
 
    frmPos=[left-frmBorder 7 ...
        right-left+frmBorder*2 top-bottom+frmBorder*2]+[1 0 1 0];
    clsFrmHndl=uicontrol( ...
        'Style','frame', ...
        'Units','pixel', ...
        'Position',frmPos, ...
        'BackgroundColor',frmColor);
    %------------------------------------
    % The postion text window
    pos1=[right-frmBorder-2*btnWid-spacing*.5 bottom 1.5*btnWid btnHt];
    helpHndl=uicontrol( ...
        'Style','text', ...
        'BackgroundColor',frmColor, ...
        'HorizontalAlignment','left', ...
        'Units','pixel', ...
        'Position',pos1, ...
        'String','Move:');

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

    %------------------------------------
    % The CLOSE button
    labelStr='Close';
    callbackStr='fisgui #close';
    closeHndl=uicontrol( ...
        'Style','push', ...
        'Position',[right-btnWid bottom-40 btnWid btnHt], ...
        'BackgroundColor',btnColor, ...
        'String',labelStr, ...
        'Callback',callbackStr);
    %------------------------------------
    % The shift horizontal button
    labelStr='left';
    callbackStr='ruleview #shiftleft';
    left=left+37;
    btnWid1= btnWid*2/5;
    closeHndl=uicontrol( ...
        'Style','push', ...
        'Position',[left 53 btnWid*2/5 btnHt], ...
        'BackgroundColor',btnColor, ...
        'String',labelStr, ...
        'Callback',callbackStr);

    % The shift horizontal button
    labelStr='right';
    callbackStr='ruleview #shiftright';
    closeHndl=uicontrol( ...
        'Style','push', ...
        'Position',[left+38 53 btnWid1 btnHt], ...
        'BackgroundColor',btnColor, ...
        'String',labelStr, ...
        'Callback',callbackStr);

    % The shift horizontal button
    labelStr='down';
    callbackStr='ruleview #shiftdown';
    closeHndl=uicontrol( ...
        'Style','push', ...
        'Position',[left+76 53 btnWid1 btnHt], ...
        'BackgroundColor',btnColor, ...
        'String',labelStr, ...
        'Callback',callbackStr);
    labelStr='up';
    callbackStr='ruleview #shiftup';
    closeHndl=uicontrol( ...
        'Style','push', ...
        'Position',[left+114 53 btnWid1 btnHt], ...
        'BackgroundColor',btnColor, ...
        'String',labelStr, ...
        'Callback',callbackStr);
%    callbackStr='ruleview #slidehori';
%    closeHndl=uicontrol( ...
%        'Style','slide', ...
%        'Position',[20 90 3*btnWid btnHt], ...
%        'Max', 2,...
%        'Min', -2,...
%        'Value', 0, ...
%        'BackgroundColor',btnColor, ...
%        'String',labelStr, ...
%        'Callback',callbackStr);


    %====================================

⌨️ 快捷键说明

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