滑模控制基本思想

 

 

 

代码如下(matlab编程):

被控对象:

function x = mass(x,u,f,t)
    x1 = x(1);
    x2 = x(2);
    dx1 = x2;
    dx2 = u+f;
    x1 = x1+dx1*t;
    x2 = x2+dx2*t;
    x = [x1,x2];
end

滑模控制器:

function [u,inf_out] = SMC(x,inf_in,parameter)
    x1 = x(1);
    x2 = x(2);
    c = inf_in(1);
    rho = parameter;
    sigma = x2+c*x1;
    u = -c*x2-rho*sign(sigma);
    inf_out = sigma;
end

仿真程序:

clc;clear;
close
%% 变量定义
length = 10000; % 迭代次数
dt = 0.001; % 步长
t = zeros(length,1);

x = zeros(2,1);
x1 = zeros(length,1); % 状态变量
x2 = zeros(length,1); % 状态变量
f = zeros(length,1); % 干扰
u = zeros(length,1); % 控制量

c = 1.5;
rho = 2;
inf_in = c;
parameter = rho;
sigma = zeros(length,1);

%% 初始化
i = 1;
t(i) = (i-1)*dt;
x1(i) = 1;
x2(i) = -2;
x = [x1(i),x2(i)];
f(i) = sin(2*t(i));
[u(i),sigma(i)] = SMC(x,inf_in,parameter);

%% 迭代循环
for i = 2:1:length
    x = mass(x,u(i-1),f(i-1),dt);
    x1(i) = x(1);
    x2(i) = x(2);
    [u(i),sigma(i)] = SMC(x,inf_in,parameter);
    t(i) = (i-1)*dt;
    f(i) = sin(2*t(i));
end

%% 绘图
figure(1);
plot(t,sigma,'linewidth',2);
hold on;
grid on;
xlabel('time(s)');
ylabel('Sliding variable');

figure(2);
plot(t,x1,'-.','linewidth',2);
hold on;
grid on;
plot(t,x2,'linewidth',2);
xlabel('time(s)');
ylabel('x(m)');
legend('x1','x2');

figure(3);
plot(x1,x2,'linewidth',2);
hold on;
grid on;
xlabel('x1');
ylabel('x2');

figure(4);
plot(t,u,'linewidth',2);
hold on;
grid on;
xlabel('time(s)');
ylabel('u');

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值