%三阶系统阶跃响应速度与r的关系(成正比)
clc,clear,clf
h=0.001;T=50;N=T/h;
n=0:N;t=n*h;
% v0=ones(1,N);
t0 = 0; % t0表示阶跃信号突变的时刻
v0 = stepfun(t,t0); % 输入单位阶跃信号
x1=zeros(1,N);x2=zeros(1,N);x3=zeros(1,N);
%% r=1,a1=2.3,a2=20
r=1;a1=2.3;a2=20;
for i=1:N
x1(i+1)=x1(i)+h*x2(i);
x2(i+1)=x2(i)+h*x3(i);
x3(i+1)=x3(i)+h*(-r^3*(x1(i)-v0(i))-r^2*a1*x2(i)-r*a2*x3(i));
y(i+1)=x1(i+1);
end
subplot(231);plot(t,y,'k','LineWidth',1.5)
hold on;plot(t,v0,'k-.','LineWidth',1)
% xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,50,0,1.5]); % 设置坐标轴上下限
set(gca,'XTick',[0:50:50]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.5:1.5]); %设置要显示坐标刻度
axis_h=gca; % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1,0.25,'$r=1,a_1=2.3,a_2=20$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
%% r=1,a1=1.8,a2=20
r=1;a1=1.8;a2=20;
for i=1:N
x1(i+1)=x1(i)+h*x2(i);
x2(i+1)=x2(i)+h*x3(i);
x3(i+1)=x3(i)+h*(-r^3*(x1(i)-v0(i))-r^2*a1*x2(i)-r*a2*x3(i));
y(i+1)=x1(i+1);
end
subplot(232);plot(t,y,'k','LineWidth',1.5)
hold on;plot(t,v0,'k-.','LineWidth',1)
% xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,50,0,2]); % 设置坐标轴上下限
set(gca,'XTick',[0:50:50]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.5:2]); %设置要显示坐标刻度
axis_h=gca; % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1,0.25,'$r=1,a_1=1.8,a_2=20$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
%% r=1,a1=2.3,a2=15
r=1;a1=2.3;a2=15;
for i=1:N
x1(i+1)=x1(i)+h*x2(i);
x2(i+1)=x2(i)+h*x3(i);
x3(i+1)=x3(i)+h*(-r^3*(x1(i)-v0(i))-r^2*a1*x2(i)-r*a2*x3(i));
y(i+1)=x1(i+1);
end
subplot(233);plot(t,y,'k','LineWidth',1.5)
hold on;plot(t,v0,'k-.','LineWidth',1)
% xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,50,0,1.5]); % 设置坐标轴上下限
set(gca,'XTick',[0:50:50]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.5:1.5]); %设置要显示坐标刻度
axis_h=gca; % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1,0.25,'$r=1,a_1=2.3,a_2=15$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
%% r=3,a1=2.3,a2=20
r=3;a1=2.3;a2=20;
for i=1:N
x1(i+1)=x1(i)+h*x2(i);
x2(i+1)=x2(i)+h*x3(i);
x3(i+1)=x3(i)+h*(-r^3*(x1(i)-v0(i))-r^2*a1*x2(i)-r*a2*x3(i));
y(i+1)=x1(i+1);
end
subplot(234);plot(t,y,'k','LineWidth',1.5)
hold on;plot(t,v0,'k-.','LineWidth',1)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,50,0,1.5]); % 设置坐标轴上下限
set(gca,'XTick',[0:50:50]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.5:1.5]); %设置要显示坐标刻度
axis_h=gca; % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1,0.25,'$r=3,a_1=2.3,a_2=20$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
%% r=3,a1=1.8,a2=20
r=3;a1=1.8;a2=20;
for i=1:N
x1(i+1)=x1(i)+h*x2(i);
x2(i+1)=x2(i)+h*x3(i);
x3(i+1)=x3(i)+h*(-r^3*(x1(i)-v0(i))-r^2*a1*x2(i)-r*a2*x3(i));
y(i+1)=x1(i+1);
end
subplot(235);plot(t,y,'k','LineWidth',1.5)
hold on;plot(t,v0,'k-.','LineWidth',1)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,50,0,2]); % 设置坐标轴上下限
set(gca,'XTick',[0:50:50]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.5:2]); %设置要显示坐标刻度
axis_h=gca; % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1,0.25,'$r=3,a_1=1.8,a_2=20$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
%% r=3,a1=2.3,a2=15
r=3;a1=2.3;a2=15;
for i=1:N
x1(i+1)=x1(i)+h*x2(i);
x2(i+1)=x2(i)+h*x3(i);
x3(i+1)=x3(i)+h*(-r^3*(x1(i)-v0(i))-r^2*a1*x2(i)-r*a2*x3(i));
y(i+1)=x1(i+1);
end
subplot(236);plot(t,y,'k','LineWidth',1.5)
hold on;plot(t,v0,'k-.','LineWidth',1)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,50,0,1.5]); %设置坐标轴上下限
set(gca,'XTick',[0:50:50]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.5:1.5]); %设置要显示坐标刻度
axis_h=gca; % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1,0.25,'$r=3,a_1=2.3,a_2=15$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
%下面一行代码在latex中运行正常,在matlab中运行有误
% sgtitle('${\dddot x}=-r^3(x-u)-r^2 a_1 \dot x -r a_2 \ddot x$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)