首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在matlab的anfis.m中获得隶属函数的训练范围?

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

Stack Overflow用户
提问于 2020-09-30 02:39:06
回答 1查看 208关注 0票数 0

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

代码语言:javascript
复制
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列用于输出)。我使用matlab内置的genfis1和anfis。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-30 05:29:59

您可以通过以下方式访问i-th input的j-th隶属函数的所有参数:

代码语言:javascript
复制
fis.input(i).mf(j).params

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

代码语言:javascript
复制
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

​

​

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64125683

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档