| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2144 人关注过本帖
标题:matlab仿真 evalfis出错,求助!
只看楼主 加入收藏
jieziloveyou
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-5-10
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
matlab仿真 evalfis出错,求助!
matlab实现变论域模糊控制出错,三个输入,三个输出
function[sys,x0,str,ts]=bly(t,x,u,flag)

switch flag,
    case 0
        [sys,x0,str,ts]=mdlInitializeSizes;
    case 3
        sys=mdlOutputs(t,x,u);
    case {1,2,4,9}
    sys=[];
    otherwise
    error(['unhandled flag=',num2str(flag)]);
end

function[sys,x0,str,ts]=mdlInitializeSizes
sizes=simsizes;
sizes.NumContStates=0;
sizes.NumDiscStates=0;
sizes.NumOutputs=3;
sizes.NumInputs=3;
sizes.DirFeedthrough=1;
sizes.NumSampleTimes=1;
sys=simsizes(sizes);
x0=[];
str=[];
ts=[-1 0];



function sys=mdlOutputs(t,x,u)

n=u(3);

a=newfis('bly');
a=addvar(a,'input','e',[-6*n 6*n]);
a=addmf(a,'input',1,'NB','zmf',[-6,-2.667]*n);
a=addmf(a,'input',1,'NM','trimf',[-6,-2.667,-0.667]*n);
a=addmf(a,'input',1,'NS','trimf',[-2.667,-0.667,0]*n);
a=addmf(a,'input',1,'ZO','trimf',[-0.667,0,0.667]*n);
a=addmf(a,'input',1,'PS','trimf',[0,0.667,2.667]*n);
a=addmf(a,'input',1,'PS','trimf',[0.667,2.667,6]*n);
a=addmf(a,'input',1,'PB','smf',[2.667,6]*n);

a=addvar(a,'input','de',[-6*n 6*n]);
a=addmf(a,'input',2,'NB','zmf',[-6,-2.667]*n);
a=addmf(a,'input',2,'NM','trimf',[-6,-2.667,-0.667]*n);
a=addmf(a,'input',2,'NS','trimf',[-2.667,-0.667,0]*n);
a=addmf(a,'input',2,'ZO','trimf',[-0.667,0,0.667]*n);
a=addmf(a,'input',2,'PS','trimf',[0,0.667,2.667]*n);
a=addmf(a,'input',2,'PS','trimf',[0.667,2.667,6]*n);
a=addmf(a,'input',2,'PB','smf',[2.667,6]*n);

a=addvar(a,'output','u',[-6 6]);
a=addmf(a,'output',1,'NB','zmf',[-6,-2.667]);
a=addmf(a,'output',1,'NM','trimf',[-6,-2.667,-0.667]);
a=addmf(a,'output',1,'NS','trimf',[-2.667,-0.667,0]);
a=addmf(a,'output',1,'ZO','trimf',[-0.667,0,0.667]);
a=addmf(a,'output',1,'PS','trimf',[0,0.667,2.667]);
a=addmf(a,'output',1,'PS','trimf',[0.667,2.667,6]);
a=addmf(a,'output',1,'PB','smf',[2.667,6]);

a=addvar(a,'output','i',[-6 6]);
a=addmf(a,'output',2,'NB','zmf',[-6,-2.667]);
a=addmf(a,'output',2,'NM','trimf',[-6,-2.667,-0.667]);
a=addmf(a,'output',2,'NS','trimf',[-2.667,-0.667,0]);
a=addmf(a,'output',2,'ZO','trimf',[-0.667,0,0.667]);
a=addmf(a,'output',2,'PS','trimf',[0,0.667,2.667]);
a=addmf(a,'output',2,'PS','trimf',[0.667,2.667,6]);
a=addmf(a,'output',2,'PB','smf',[2.667,6]);

a=addvar(a,'output','d',[-6 6]);
a=addmf(a,'output',3,'NB','zmf',[-6,-2.667]);
a=addmf(a,'output',3,'NM','trimf',[-6,-2.667,-0.667]);
a=addmf(a,'output',3,'NS','trimf',[-2.667,-0.667,0]);
a=addmf(a,'output',3,'ZO','trimf',[-0.667,0,0.667]);
a=addmf(a,'output',3,'PS','trimf',[0,0.667,2.667]);
a=addmf(a,'output',3,'PS','trimf',[0.667,2.667,6]);
a=addmf(a,'output',3,'PB','smf',[2.667,6]);
ruleList=[1 1 7 1 5 1 1;
          1 2 7 1 3 1 1;
          1 3 6 2 1 1 1;
          1 4 6 2 1 1 1;
          1 5 5 3 1 1 1;
          1 6 4 4 2 1 1;
          1 7 4 4 5 1 1;
         
          2 1 7 1 5 1 1;
          2 2 7 1 3 1 1;
          2 3 6 2 1 1 1;
          2 4 5 3 2 1 1;
          2 5 5 3 2 1 1;
          2 6 4 4 3 1 1;
          2 7 3 4 4 1 1;
         
          3 1 6 1 4 1 1;
          3 2 6 2 3 1 1;
          3 3 6 3 2 1 1;
          3 4 5 3 2 1 1;
          3 5 4 4 3 1 1;
          3 6 3 5 3 1 1;
          3 7 3 5 4 1 1;
         
          4 1 6 2 4 1 1;
          4 2 6 2 3 1 1;
          4 3 5 3 3 1 1;
          4 4 4 4 3 1 1;
          4 5 3 5 3 1 1;
          4 6 2 6 3 1 1;
          4 7 2 6 4 1 1;
         
          5 1 5 2 4 1 1;
          5 2 5 3 4 1 1;
          5 3 4 4 4 1 1;
          5 4 3 5 4 1 1;
          5 5 3 5 4 1 1;
          5 6 2 6 4 1 1;
          5 7 2 7 4 1 1;
         
          6 1 5 4 7 1 1;
          6 2 4 4 5 1 1;
          6 3 3 5 5 1 1;
          6 4 2 5 5 1 1;
          6 5 2 6 5 1 1;
          6 6 2 7 5 1 1;
          6 7 1 7 7 1 1;

          7 1 4 4 7 1 1;
          7 2 4 4 6 1 1;
          7 3 2 5 6 1 1;
          7 4 2 6 6 1 1;
          7 5 2 6 5 1 1;
          7 6 1 7 5 1 1;
          7 7 1 7 7 1 1];

a=addrule(a,ruleList);
e1=u(1);
de1=u(2);
if e1>6*n
    e1=6*n;%限制误差在基本论域
end
if e1<-6*n
   e1=-6*n;
end
if de1>6*n
    de1=6*n; %限制误差变化率
end
if de1<6*n
    de1=-6*n;
end
in=[e1,de1];
sys=evalfis(in,a);

报错:
??illegal parameters in fisTriangleMf() -->a-->b

Error in ==>evalfis at 81
[output,IRR,ORR,ARR]=evalfismex(input,fis,numfpoints);

Error in ==>bly>mdloutputs at 138
sys=evalfis(in,a)

Error in ==>bly at 7
sys=mdlOutput(t,x,u)
搜索更多相关主题的帖子: otherwise function matlab 
2015-05-10 10:42
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:20 
帮不上
2015-05-10 14:24
快速回复:matlab仿真 evalfis出错,求助!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039126 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved