clear all;close all;
%%%%%%%%%%%%%%%%%%%%% Fuzzy System Design %%%%%%%%%%%%%%%%%%%%
a=newfis('fuzz_smc');
k1=1.0;
a=addvar(a,'input','s',[-3*k1,3*k1]); % Parameter s
a=addmf(a,'input',1,'NB','zmf',[-3*k1,-1*k1]);
a=addmf(a,'input',1,'NM','trimf',[-3*k1,-2*k1,0]);
a=addmf(a,'input',1,'NS','trimf',[-3*k1,-1*k1,1*k1]);
a=addmf(a,'input',1,'Z','trimf',[-2*k1,0,2*k1]);
a=addmf(a,'input',1,'PS','trimf',[-1*k1,1*k1,3*k1]);
a=addmf(a,'input',1,'PM','trimf',[0,2*k1,3*k1]);
a=addmf(a,'input',1,'PB','smf',[1*k1,3*k1]);
k2=1.0;
a=addvar(a,'input','ds',[-3*k2,3*k2]); % Parameter ds
a=addmf(a,'input',2,'NB','zmf',[-3*k2,-1*k2]);
a=addmf(a,'input',2,'NM','trimf',[-3*k2,-2*k2,0]);
a=addmf(a,'input',2,'NS','trimf',[-3*k2,-1*k2,1*k2]);
a=addmf(a,'input',2,'Z','trimf',[-2*k2,0,2*k2]);
a=addmf(a,'input',2,'PS','trimf',[-1*k2,1*k2,3*k2]);
a=addmf(a,'input',2,'PM','trimf',[0,2*k2,3*k2]);
a=addmf(a,'input',2,'PB','smf',[1*k2,3*k2]);
k3=1.0;
a=addvar(a,'output','du',[-3*k3,3*k3]); % Parameter du
a=addmf(a,'output',1,'NB','zmf',[-3*k3,-1*k3]);
a=addmf(a,'output',1,'NM','trimf',[-3*k3,-2*k3,0]);
a=addmf(a,'output',1,'NS','trimf',[-3*k3,-1*k3,1*k3]);
a=addmf(a,'output',1,'Z','trimf',[-2*k3,0,2*k3]);
a=addmf(a,'output',1,'PS','trimf',[-1*k3,1*k3,3*k3]);
a=addmf(a,'output',1,'PM','trimf',[0,2*k3,3*k3]);
a=addmf(a,'output',1,'PB','smf',[1*k3,3*k3]);
rulelist=[1 1 1 1 1; % Fuzzy rule base
1 2 1 1 1;
1 3 2 1 1;
1 4 2 1 1;
1 5 3 1 1;
1 6 3 1 1;
1 7 4 1 1;
2 1 1 1 1;
2 2 2 1 1;
2 3 2 1 1;
2 4 3 1 1;
2 5 3 1 1;
2 6 4 1 1;
2 7 5 1 1;
3 1 2 1 1;
3 2 2 1 1;
3 3 3 1 1;
3 4 3 1 1;
3 5 4 1 1;
3 6 5 1 1;
3 7 5 1 1;
4 1 2 1 1;
4 2 3 1 1;
4 3 3 1 1;
4 4 4 1 1;
4 5 5 1 1;
4 6 5 1 1;
4 7 6 1 1;
5 1 3 1 1;
5 2 3 1 1;
5 3 4 1 1;
5 4 5 1 1;
5 5 5 1 1;
5 6 6 1 1;
5 7 6 1 1;
6 1 3 1 1;
6 2 4 1 1;
6 3 5 1 1;
6 4 5 1 1;
6 5 6 1 1;
6 6 6 1 1;
6 7 7 1 1;
7 1 4 1 1;
7 2 5 1 1;
7 3 5 1 1;
7 4 6 1 1;
7 5 6 1 1;
7 6 7 1 1;
7 7 7 1 1];
a=addrule(a,rulelist);
%showrule(a) % Show fuzzy rule base
%ruleview(a)
a1=setfis(a,'DefuzzMethod','centroid'); % Defuzzy
writefis(a1,'fsmc'); % Save to fuzzy file "fsmc.fis"
a2=readfis('fsmc');
%%%%%%%%%%%%%%%%%%%%% Fuzzy SMC Control %%%%%%%%%%%%%%%%%%%%
ts=0.001;
sys=tf([133],[1,25,0]);
dsys=c2d(sys,ts,'z');
[num,den]=tfdata(dsys,'v');
e_1=0;de_1=0;s_1=0;
u_1=0.0;u_2=0.0;
y_1=0.0;y_2=0.0;
for k=1:1:2000
time(k)=k*ts;
M=1;
if M==1
rin(k)=1; %Step Signal
end
if M==2
rin(k)=sign(sin(1*2*pi*k*ts)); %Square Signal
end
if M==3
rin(k)=sin(2*2*pi*k*ts); %Sine Signal
end
%Linear model
yout(k)=-den(2)*y_1-den(3)*y_2+num(2)*u_1+num(3)*u_2;
e(k)=rin(k)-yout(k);
de(k)=(e(k)-e_1)/ts;
c=15;
s(k)=c*e(k)+1*de(k);
s1(k)=s(k)-s_1;
du(k)=evalfis([s(k) s1(k)],a2); %Fuzzy Slide Mode Controler
u(k)=u_1+du(k);
if u(k)>=10
u(k)=10;
end
if u(k)<=-10
u(k)=-10;
end
e_1=e(k);
de_1=de(k);
s_1=s(k);
u_2=u_1;u_1=u(k);
y_2=y_1;y_1=yout(k);
end
figure(1);
plot(time,rin,'r',time,yout,'b');
xlabel('time(s)');ylabel('rin,yout');
figure(2);
plot(e,de,'b',e,-c*e,'r');
xlabel('e');ylabel('de');
figure(3);
plot(time,s,'r');
xlabel('time(s)');ylabel('s');
figure(4);
plot(time,u,'r');
xlabel('time(s)');ylabel('u');
figure(5);
plotmf(a2,'input',1);
figure(6);
plotmf(a2,'input',2);
figure(7);
plotmf(a2,'output',1);
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
滑模控制MATLAB仿真仿真程序.rar (220个子文件)
fsmc.fis 2KB
fuzz.fis 648B
smc_fuzz.fis 607B
chap4_1.m 4KB
chap9_2s.m 4KB
chap4_7s.m 3KB
chap4_7s.m 3KB
chap4_6s.m 2KB
chap4_2.m 2KB
chap3_5s.m 2KB
chap10_2s.m 2KB
chap10_4s.m 2KB
chap9_8s.m 2KB
chap5_3.m 2KB
chap4_5s.m 2KB
chap4_4rule.m 2KB
chap4_3rule.m 2KB
chap4_9s.m 2KB
chap5_5s.m 2KB
chap5_1.m 2KB
chap5_6s.m 2KB
chap4_8s.m 2KB
chap8_4.m 2KB
chap9_3s.m 2KB
chap3_6.m 2KB
chap3_3.M 2KB
chap2_7plant.m 2KB
chap5_2s.m 2KB
chap3_7.m 2KB
chap3_7.m 2KB
chap10_1s.m 1KB
chap9_1s.m 1KB
chap8_3.m 1KB
chap3_8.m 1KB
chap8_6.m 1KB
chap9_8plant.m 1KB
chap2_6.m 1KB
chap4_4plant.m 1KB
chap5_7s.m 1KB
chap5_7s.m 1KB
chap9_6s.m 1KB
chap10_4plant.m 1KB
chap5_6plant.m 1KB
chap8_5.m 1KB
chap4_4s.m 1KB
chap4_6plant.m 1KB
chap10_7s.m 1KB
chap4_3s.m 1KB
chap4_7plant.m 1KB
chap6_4s2.m 1KB
chap9_7s.m 1KB
chap6_5plantn.m 1KB
chap6_5plantn.m 1KB
chap5_4s.m 1KB
chap6_5plant.m 1KB
chap6_5plant.m 1KB
chap9_2plant.m 1KB
chap2_8s.m 1KB
chap2_5.m 1KB
chap10_6s.m 1KB
chap9_4s.m 1KB
chap9_5s.m 1KB
chap3_2.m 1KB
chap10_3s.m 1KB
chap4_8plant1.m 1KB
chap7_2s.m 1KB
chap5_7plant.m 1KB
chap5_7plant.m 1KB
chap7_4s.m 1024B
chap3_4.m 1022B
chap4_3plant.m 1022B
chap7_5s.m 1017B
chap8_2plant.m 1014B
chap6_4s1.m 1011B
chap2_8plant.m 989B
chap9_3plant.m 981B
chap10_8s.m 974B
chap4_5plant.m 970B
chap10_2plant.m 957B
chap6_3s.m 952B
chap8_2s.m 927B
chap6_2s.m 926B
chap10_5s.m 906B
chap10_3plant.m 904B
chap5_4plant.m 894B
chap2_7s.m 887B
chap9_6plant.m 887B
chap7_1plant.m 883B
chap6_2plant.m 879B
chap6_3plant.m 879B
chap6_4plant2.m 877B
chap5_5plant.m 873B
chap7_2plant.m 869B
chap4_8plant.m 868B
chap9_7plant.m 858B
chap9_4plant.m 854B
chap7_1s.m 853B
chap6_4plant1.m 834B
chap7_3s.m 834B
chap9_5plant.m 830B
共 220 条
- 1
- 2
- 3
资源评论
- df5954204692023-07-27这个文件提供了一个很好的滑模控制MATLAB仿真程序,非常便于初学者理解和学习。
- 普通网友2023-07-27只需要一些简单的MATLAB基础,就可以轻松运行和理解这个MATLAB仿真程序。
- 西西里的小裁缝2023-07-27文件中的MATLAB仿真程序非常简洁实用,对于需要快速上手滑模控制的用户来说是一个很好的选择。
- 鸣泣的海猫2023-07-27仿真程序很实用,可以帮助用户更好地掌握滑模控制算法的原理与应用。
- 苗苗小姐2023-07-27对于毫无经验的用户来说,这个文件提供了一个很好的起点,可以迅速掌握滑模控制算法的基本原理。
深度学习小能手
- 粉丝: 3
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功