如何在matlab的anfis.m中获得隶属函数的训练范围?

How to get trained ranges for membership functions in anfis.m of matlab?

我需要在 matlab 的 anfis 中获取输入的隶属函数范围。我使用以下代码训练我的网络并成功训练网络。但我需要的是获取网络为输入的隶属函数找到的范围值。我的意思是如果隶属函数是钟形的,比如 gbellmf,它会有这个公式 (x)= exp{-((x-c)/a)^(2*b)} 我需要知道 abc网络训练完成后。


function trainedfis = main(data,chkdata)
    
fis = genfis1(data,[3 3 3],char('gbellmf','gbellmf', 'gbellmf'));
    
[trainedfis,errors,stepssize,chkfis,errchk] = anfis(data,fis,3,[1 1 1 1],chkdata);
        
end

我的数据也是三输入一输出数据(3 列用于输入,1 列用于输出)。 我使用内置的 genfis1anfis 的 matlab。

您可以通过以下方式访问第 i 个输入的第 j 个隶属函数的所有参数:

fis.input(i).mf(j).params

在下面的示例中,我为 Iris 数据训练了 fis,它有 4 个输入。然后我使用存储在 fismat 中的数据绘制所有隶属函数:

close all; clc; clear variable;
%% import iris data
[x, t] = iris_dataset;
y = t(1, :)*1 + t(1, :)*2 + t(3, :)*3;
data = [x' y'];
%% train fis moddel
numMFs = [3 3 3 3];
mfType = char('gbellmf','gbellmf', 'gbellmf', 'gbellmf');
fismat = genfis1(data,numMFs,mfType);

%% plot input membership function using plotmf
subplot(2,2,1), plotmf(fismat,'input',1);
subplot(2,2,2), plotmf(fismat,'input',2);
subplot(2,2,3), plotmf(fismat,'input',3);
subplot(2,2,4), plotmf(fismat,'input',4);

%% plot input membership function manually, using fismat object
figure;
% get number of inputs
ni = numel(fismat.input);
for i=1:ni
    % get total range of all mem-funs of i-th input
    range = fismat.input(i).range; 
    subplot(2, 2, i);
    xlabel(['input ' num2str(i)]);
    xlim(range); hold on;
    x = linspace(range(1), range(2), 100);
    % get number of mem-funs of i-th input
    nmf = numel(fismat.input(i).mf);
    for j=1:nmf
        % get j-th mem-fun of i-th input
        mf = str2func(fismat.input(i).mf(j).type);
        % get parameters of j-th mem-fun of i-th input
        params = fismat.input(i).mf(j).params;
        y = mf(x, params);
        plot(x, y, 'displayname', ...
            [fismat.input(i).mf(j).type '(' num2str(params, '%.1f,') ')']);
    end
    legend('show')
end