t-s模糊matlab编程
时间: 2023-08-10 21:06:00 浏览: 110
T-S模糊是一种常用的模糊控制方法,它将模糊控制器的设计问题转化为一系列的模糊规则。在Matlab中,可以使用fuzzy logic toolbox工具箱来实现T-S模糊控制器的设计。
下面是一个简单的T-S模糊控制器的Matlab代码示例:
```matlab
% 定义输入变量
input1 = newfis('input1');
input1 = addvar(input1,'input','[-10 10]');
input1 = addmf(input1,'input',1,'nb','zmf',[-10 -5]);
input1 = addmf(input1,'input',2,'nm','gaussmf',[1 -3]);
input1 = addmf(input1,'input',3,'ns','gaussmf',[1 -1]);
input1 = addmf(input1,'input',4,'z','gaussmf',[1 0]);
input1 = addmf(input1,'input',5,'ps','gaussmf',[1 1]);
input1 = addmf(input1,'input',6,'pm','gaussmf',[1 3]);
input1 = addmf(input1,'input',7,'pb','smf',[5 10]);
% 定义输出变量
output1 = newfis('output1');
output1 = addvar(output1,'output','[-10 10]');
output1 = addmf(output1,'output',1,'nb','zmf',[-10 -5]);
output1 = addmf(output1,'output',2,'nm','gaussmf',[1 -3]);
output1 = addmf(output1,'output',3,'ns','gaussmf',[1 -1]);
output1 = addmf(output1,'output',4,'z','gaussmf',[1 0]);
output1 = addmf(output1,'output',5,'ps','gaussmf',[1 1]);
output1 = addmf(output1,'output',6,'pm','gaussmf',[1 3]);
output1 = addmf(output1,'output',7,'pb','smf',[5 10]);
% 定义模糊规则
rule1 = [1 1 1 1 1; 1 2 2 1 1; 1 3 3 1 1; 1 4 4 1 1; 1 5 5 1 1; 1 6 6 1 1; 1 7 7 1 1];
rule2 = [2 1 2 1 1; 2 2 3 1 1; 2 3 4 1 1; 2 4 5 1 1; 2 5 6 1 1; 2 6 7 1 1];
rule3 = [3 1 3 1 1; 3 2 4 1 1; 3 3 5 1 1; 3 4 6 1 1; 3 5 7 1 1];
rule4 = [4 1 4 1 1; 4 2 5 1 1; 4 3 6 1 1; 4 4 7 1 1];
rule5 = [5 1 5 1 1; 5 2 6 1 1; 5 3 7 1 1];
rule6 = [6 1 6 1 1; 6 2 7 1 1];
rule7 = [7 1 7 1 1];
% 将模糊变量和规则添加到模糊系统中
fis = newfis('fis');
fis = addvar(fis,'input','input1');
fis = addvar(fis,'output','output1');
fis = addrule(fis,[rule1; rule2; rule3; rule4; rule5; rule6; rule7]);
% 运行模糊控制器
input = 5;
output = evalfis(input,fis);
```
在这个示例中,我们首先定义了输入变量和输出变量,然后定义了模糊规则,并将它们添加到模糊系统中。最后,我们可以使用evalfis函数来运行模糊控制器。
需要注意的是,这只是一个简单的示例,实际的T-S模糊控制器设计可能需要更复杂的模糊规则和更多的输入和输出变量。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)