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

📄 getfis.m

📁 模糊控制工具箱,很好用的,有相应的说明文件,希望对大家有用!
💻 M
📖 第 1 页 / 共 2 页
字号:
function out=getfis(fis,arg1,arg2,arg3,arg4,arg5)
%GETFIS Get fuzzy inference system properties.
%   OUT = GETFIS(FIS) returns a list of general information about the
%   fuzzy inference system FIS.
%   OUT = GETFIS(FIS,'fisProp') returns the current value of the FIS
%   property called 'fisProp'.
%   OUT = GETFIS(FIS, 'vartype', 'varindex') returns a general list
%   of information on 'vartype' of 'varindex'.
%   OUT = GETFIS(FIS, 'vartype', 'varindex', 'varprop') returns the
%   current value in 'varprop' for 'vartype' of 'varindex'.
%   OUT = GETFIS(FIS, 'vartype', 'varindex', 'mf', 'mfindex')
%   returns a general list of information on membership function
%   'mfindex'
%   OUT = GETFIS(FIS, 'vartype', 'varindex', 'mf', 'mfindex', 'mfprop')
%   returns the current value in 'mfprop' for 'mf' of 'mfindex'
%
%   For example:
%
%           a=newfis('tipper');
%           a=addvar(a,'input','service',[0 10]);
%           a=addmf(a,'input',1,'poor','gaussmf',[1.5 0]);
%           a=addmf(a,'input',1,'excellent','gaussmf',[1.5 10]);
%           getfis(a)
%
%   See also SETFIS, SHOWFIS.


%   Ned Gulley, 2-2-94, Kelly Liu 7-10-96
%   Copyright 1994-2005 The MathWorks, Inc.
%   $Revision: 1.33.2.2 $  $Date: 2005/06/27 22:36:54 $


if isfield(fis, 'input')
    numInputs=length(fis.input);
else
    numInputs=0;
end

if isfield(fis, 'output')
    numOutputs=length(fis.output);
else
    numOutputs=0;
end

switch nargin
    case 1,
        % ===============================================
        % Handle generic inquiries related to the whole fis
        % ===============================================

        fprintf('      Name      = %s\n',fis.name);
        fprintf('      Type      = %s\n',fis.type);
        fprintf('      NumInputs = %s\n',num2str(numInputs));
        fprintf('      InLabels  = \n');
        if numInputs~=0,
            for i=1:length(fis.input)
                fprintf('            %s\n',fis.input(i).name);
            end
        end
        fprintf('      NumOutputs = %s\n',num2str(numOutputs));
        fprintf('      OutLabels = \n');
        if numOutputs~=0,
            for i=1:length(fis.output)
                fprintf('            %s\n',fis.output(i).name);
            end
        end
        fprintf('      NumRules = %s\n',num2str(length(fis.rule)));
        fprintf('      AndMethod = %s\n',fis.andMethod);
        fprintf('      OrMethod = %s\n',fis.orMethod);
        fprintf('      ImpMethod = %s\n',fis.impMethod);
        fprintf('      AggMethod = %s\n',fis.aggMethod);
        fprintf('      DefuzzMethod = %s\n',fis.defuzzMethod);
        out=fis.name;

    case 2,
        % ===============================================
        propName=lower(arg1);
        switch propName
            case 'name'
                out=fis.name;
            case 'type';
                out=fis.type;
            case 'numinputs'
                out=numInputs;
            case 'numoutputs'
                out=numOutputs;
            case 'numinputmfs'
                numInputMFs=[];
                for i=1:length(fis.input)
                    numInputMFs(i)=length(fis.input(i).mf);
                end
                out=numInputMFs;
            case 'numoutputmfs'
                numOutputMFs=[];
                for i=1:length(fis.output)
                    numOutputMFs(i)=length(fis.output(i).mf);
                end
                out=numOutputMFs;

            case 'numrules'
                out=length(fis.rule);
            case 'andmethod'
                out=fis.andMethod;
            case 'ormethod'
                out=fis.orMethod;
            case 'impmethod'
                out=fis.impMethod;
            case 'aggmethod'
                out=fis.aggMethod;
            case 'defuzzmethod'
                out=fis.defuzzMethod;

            case 'inlabels'
                out=[];
                for i=1:numInputs
                    out=strvcat(out, fis.input(i).name);
                end

            case 'outlabels'
                out=[];
                for i=1:numOutputs
                    out=strvcat(out, fis.output(i).name);
                end

            case 'inrange'
                for i=1:numInputs
                    out(i, 1:2)=fis.input(i).range;
                end

            case 'outrange'
                for i=1:numOutputs
                    out(i,1:2)=fis.output(i).range;
                end

            case 'inmfs'
                for i=1:numInputs
                    out(i)=length(fis.input(i).mf);
                end

            case 'outmfs'
                for i=1:numOutputs
                    out(i)=length(fis.output(i).mf);
                end

            case 'inmflabels'
                out=[];
                for i=1:numInputs
                    for j=1:length(fis.input(i).mf)
                        out=strvcat(out, fis.input(i).mf(j).name);
                    end
                end

            case 'outmflabels'
                out=[];
                for i=1:numOutputs
                    for j=1:length(fis.output(i).mf)
                        out=strvcat(out, fis.output(i).mf(j).name);
                    end
                end

            case 'inmftypes'
                out=[];
                for i=1:numInputs
                    for j=1:length(fis.input(i).mf)
                        out=strvcat(out, fis.input(i).mf(j).type);
                    end
                end

            case 'outmftypes'
                out=[];
                for i=1:numOutputs
                    for j=1:length(fis.output(i).mf)
                        out=strvcat(out, fis.output(i).mf(j).type);
                    end
                end

            case 'inmfparams'
                numInputMFs=[];
                for i=1:length(fis.input)
                    numInputMFs(i)=length(fis.input(i).mf);
                end
                totalInputMFs=sum(numInputMFs);
                k=1;
                out=zeros(totalInputMFs, 4);
                for i=1:numInputs
                    for j=1:length(fis.input(i).mf)
                        temp=fis.input(i).mf(j).params;
                        out(k,1:length(temp))=temp;
                        k=k+1;
                    end
                end

            case 'outmfparams'
                numOutputMFs=[];
                for i=1:length(fis.output)
                    numOutputMFs(i)=length(fis.output(i).mf);
                end
                totalOutputMFs=sum(numOutputMFs);
                k=1;
                out=zeros(totalOutputMFs, 4);
                for i=1:numOutputs
                    for j=1:length(fis.output(i).mf)
                        temp=fis.output(i).mf(j).params;
                        out(k, 1:length(temp))=temp;
                        k=k+1;
                    end
                end

            case 'rulelist'
                out=[];
                if length(fis.rule)~=0,
                    for i=1:length(fis.rule)
                        if isempty(fis.rule(i).antecedent)
                            ermsg = sprintf('antecedent of rule %d is empty.',i);
                            error(ermsg);
                        end
                        rules(i, 1:numInputs)=fis.rule(i).antecedent;
                        
                        if isempty(fis.rule(i).consequent)
                            ermsg = sprintf('consequent of rule %d is empty.',i);
                            error(ermsg);
                        end
                        rules(i, (numInputs+1):(numInputs+numOutputs))=fis.rule(i).consequent;

⌨️ 快捷键说明

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