现控倒立摆系统分析

%% 变量赋值
m=0.1;M=1;
g=10;len=0.5;
A=[0 1 0 0 ;0 0 -m*g/M 0;0 0 0 1;0 0 (m+M)*g/(M*len) 0];
b=[0;1/M;0;-1/(M*len)];
c=[1 0 0 0];
d=0;
% 能控性分析
M=ctrb(A,b);
P=rank(M);
N=size(A,1);
%% 能观性分析
MM=ctrb(A,b);
PP=rank(MM);

if N==P
    if N==PP
        str="该系统能控能控";
    else
        str="该系统能控不能观";
    end
    
else
    if N==PP
        str="该系统不能控能观";
    else
        str="该系统不能控不能观";
    end
end
disp(str);

%% 稳定性分析
sys0=ss(A,b,c,d);
t=0:0.01:5;
[y,t,x]=step(sys0,t);
% disp(y)

figure('name','车载倒立摆系统的分析');


subplot(2,2,1);
plot(t,x(:,1),'r');
xlabel('t/s'),ylabel('x_1');
title('x1波形')%设置图标题
grid on%开启网格
% tx=text(0.5,0.05,str);
% set(tx,'fontweight','bold');
% sgtitle(str)

subplot(2,2,2);
plot(t,x(:,2),'g');
xlabel('t/s'),ylabel('x_2');
title('x2波形')%设置图标题
grid on%开启网格

subplot(2,2,3);
plot(t,x(:,3),'black');
xlabel('t/s'),ylabel('x_3');
title('x3波形')%设置图标题
grid on%开启网格

subplot(2,2,4);
plot(t,x(:,4),'b');
xlabel('t/s'),ylabel('x_4');
title('x4波形')%设置图标题
grid on%开启网格

suptitle(str);

%% 全状态反馈控制器
K1=[-43.2 -27.36 -106.6 -23.68];
K2=-43.2;
AA=[A-b*K1 b*K2;-c 0];
BB=[zeros(4,1);1];
CC=[c 0];
DD=0;
tt=0:0.01:10;
[yy,xx,tt]=step(AA,BB,CC,DD,1,tt);%1还是len呢
x1=xx(:,1);
x2=xx(:,2);
x3=xx(:,3);
x4=xx(:,4);
w=xx(:,5);


figure('name','车载倒立摆系统全状态反馈控制');

subplot(2,2,1);
plot(tt,x1,'r');
xlabel('t/s'),ylabel('x_1');
title('x1波形')%设置图标题
grid on%开启网格

subplot(2,2,2);
plot(tt,x2,'g');
xlabel('t/s'),ylabel('x_2');
title('x2波形')%设置图标题
grid on%开启网格

subplot(2,2,3);
plot(tt,x3,'black');
xlabel('t/s'),ylabel('x_3');
title('x3波形')%设置图标题
grid on%开启网格

subplot(2,2,4);
plot(tt,x4,'b');
xlabel('t/s'),ylabel('x_4');
title('x4波形')%设置图标题
grid on%开启网格

suptitle("全状态反馈控制器效果");

效果:
在这里插入图片描述

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值