跳转至

第一章

公用函数

公用函数

ddtrns.m Provided by 张聪玮 @2022-04-14
1
2
3
4
5
6
7
function y=ddtrns(T0,t)
    if t>T0
        y=0;
    else
        y=-1/2*(pi/T0)^2*sin(pi*(t/T0-1/2));
    end
end    
dtrns.m Provided by 张聪玮 @2022-04-14
1
2
3
4
5
6
7
function y=dtrns(T0,t)
    if t>T0
        y=0;
    else
        y=pi/(2*T0)*cos(pi*(t/T0-1/2));
    end
end
s.m Provided by 张聪玮 @2022-04-14
1
2
3
4
5
6
7
function y=s(t,T0)
    if t<=T0
        y=sign(t);
    else
        y=0;
    end
end
trns.m Provided by 张聪玮 @2022-04-14
1
2
3
4
5
6
7
function y=trns(T0,t)
    if t>T0
        y=1;
    else
        y=1/2*(1+sin(pi*(t/T0-1/2)));
    end
end

1.1节

1.1节

图1-1-4
图1-1-4
图1-1-4 Provided by 张聪玮 @2022-04-14
%二阶振荡环节,传递函数W(s)=1/(s^2+a2*s+a1)
%A0=k0,A1=k1+a1,A2=k2+a2,b=a1
clc,clear,clf
h=0.001;T=15;N=T/h;
n=1:N;t=n*h;
v0=1;
a1=1;a2=1;
x1=zeros(1,N);x2=zeros(1,N);
e=zeros(1,N);De=zeros(1,N);e0=zeros(1,N); %误差,误差的微分,误差的积分
e(1)=v0(1);De(1)=0;e0(1)=0;

%% 第一组增益
k0=1;k1=0.5;k2=0.5;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(221);plot(t,y,'k','LineWidth',1.5)
% xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,15,0,1.5]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(2,0.25,'$A_0=1.0,A_1=1.5,A_2=1.5$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
title('$A_0=k_0,A_1=a_1+k_1,A_2=a_2+k_2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15,'Position',[16.5,-0.68])

subplot(223);plot(t,u,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$u$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,15,0,2]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(2,0.3,'$A_0=1.0,A_1=1.5,A_2=1.5$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% 第二组增益
k0=1;k1=2.8;k2=2;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(222);plot(t,y,'k','LineWidth',1.5)
% xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,15,0,1.5]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(2,0.25,'$A_0=1.0,A_1=3.8,A_2=3.0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(224);plot(t,u,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$u$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,15,0,3]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(2,0.4,'$A_0=1.0,A_1=3.8,A_2=3.0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

sgtitle('$\ddot x=-x-\dot x+u \quad (a_1=1,a_2=1)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
% exportgraphics(gca,'code1_1_4.png','Resolution',600)

1.2节

1.2节

图1-2-1
图1-2-1
图1-2-1 Provided by 张聪玮 @2022-04-14
clc,clear,clf
a=0:0.01:5;
b1=a;
k0=1;
b2=k0./a;

plot(a,b1,'k',a,b2,'k','LineWidth',1.5);
xlabel('$\alpha$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$\beta$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,5]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[347,162,560,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.02,1,'$\alpha \cdot \beta<k_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(0.9,0.4,'$\alpha \cdot \beta<k_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(0.9,3.2,'$\alpha \cdot \beta>k_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(2.6,1.6,'$\alpha \cdot \beta>k_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)

图1-2-2
图1-2-2

图1-2-2 Provided by 张聪玮 @2022-04-14
%控制增益下调30%
%二阶振荡环节,传递函数W(s)=1/(s^2+a2*s+a1)
%A0=k0,A1=k1+a1,A2=k2+a2,b=a1
clc,clear,clf
h=0.001;T=10;N=T/h;
n=1:N;t=n*h;
v0=1;
a1=0.4;a2=0;
x1=zeros(1,N);x2=zeros(1,N);
e=zeros(1,N);De=zeros(1,N);e0=zeros(1,N); %误差,误差的微分,误差的积分
e(1)=v0(1);De(1)=0;e0(1)=0;

%% 原始参数
k0=0.25;k1=1.4;k2=2.6;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(141);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(3,0.56,'$A_0=0.25$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.41,'$A_1=1.80$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.26,'$A_2=2.60$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k0下调30%
k0=0.25*0.7;k1=1.4;k2=2.6;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(142);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(3,0.56,'$A_0=0.175$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.41,'$A_1=1.80$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.26,'$A_2=2.60$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1下调30%
k0=0.25;k1=1.4*0.7;k2=2.6;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(143);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(3,0.56,'$A_0=0.25$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.41,'$A_1=0.98$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.26,'$A_2=2.60$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k2下调30%
k0=0.25;k1=1.4;k2=2.6*0.7;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(144);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(3,0.56,'$A_0=0.25$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.41,'$A_1=1.80$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.26,'$A_2=1.82$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

sgtitle('$\ddot x=-x+u \quad (a_1=0.4,a_2=0)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-2-3
图1-2-3

图1-2-3 Provided by 张聪玮 @2022-04-14
%控制增益上调
%二阶振荡环节,传递函数W(s)=1/(s^2+a2*s+a1)
%A0=k0,A1=k1+a1,A2=k2+a2,b=a1
clc,clear,clf
h=0.001;T=10;N=T/h;
n=1:N;t=n*h;
v0=1;
a1=0.4;a2=0;
x1=zeros(1,N);x2=zeros(1,N);
e=zeros(1,N);De=zeros(1,N);e0=zeros(1,N); %误差,误差的微分,误差的积分
e(1)=v0(1);De(1)=0;e0(1)=0;

%% 原始参数
k0=0.25;k1=1.4;k2=2.6;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(141);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(3,0.56,'$A_0=0.25$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.41,'$A_1=1.80$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.26,'$A_2=2.60$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k0上调30%
k0=0.25*1.3;k1=1.4;k2=2.6;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(142);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(3,0.56,'$A_0=0.325$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.41,'$A_1=1.80$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.26,'$A_2=2.60$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1上调30%
k0=0.25;k1=1.4*1.3;k2=2.6;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(143);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(3,0.56,'$A_0=0.25$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.41,'$A_1=2.22$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.26,'$A_2=2.60$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k2上调30%
k0=0.25;k1=1.4;k2=2.6*1.3;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(144);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(3,0.56,'$A_0=0.25$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.41,'$A_1=1.80$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(3,0.26,'$A_2=3.38$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

sgtitle('$\ddot x=-x+u \quad (a_1=0.4,a_2=0)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

1.4节 1-6

1.4节

图1-4-1
图1-4-1

图1-4-1 Provided by 张聪玮 @2022-04-14
%安排过渡过程的作用
clc,clear,clf
h=0.005;T=5;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);
%% r=2
r=2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*x2(i));
    y(i+1)=x1(i+1);
end
subplot(141);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.5,0.1,'$r=2,T_0=3.5$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)


%% r=4
r=4;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*x2(i));
    y(i+1)=x1(i+1);
end
subplot(142);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.3,0.1,'$r=4,T_0=1.75$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% r=6
r=6;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*x2(i));
    y(i+1)=x1(i+1);
end
subplot(143);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.3,0.1,'$r=6,T_0=1.17$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% r=8
r=8;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*x2(i));
    y(i+1)=x1(i+1);
end
subplot(144);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.3,0.1,'$r=8,T_0=0.88$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

sgtitle('$\ddot x=-r^2(x-v_0)-2r \dot x$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-2
图1-4-2

图1-4-2 Provided by 张聪玮 @2022-04-14
%对象参数的摄动对过渡过程的影响
clc,clear,clf
h=0.005;T=5;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);
k1=2;k2=2; %固定PD的增益k1,k2

%% 原始参数a1=2;a2=2;
a1=2;a2=2;
a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i))-a_2*x2(i));
    y0(i+1)=x1(i+1);
end

%% a1=3;a2=2;
a1=3;a2=2;
a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i))-a_2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(141);plot(t,y0,'k--','LineWidth',1.5)
hold on;plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
annotation('arrow',[0.185 0.17],[0.66 0.74]);
text(0.5,1.2,'$a_1=3,a_2=2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% a1=1;a2=2;
a1=1;a2=2;
a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i))-a_2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(142);plot(t,y0,'k--','LineWidth',1.5)
hold on;plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
annotation('arrow',[0.435 0.42],[0.647 0.73]);
text(0.5,1.2,'$a_1=1,a_2=2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% a1=2;a2=3;
a1=2;a2=3;
a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i))-a_2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(143);plot(t,y0,'k--','LineWidth',1.5)
hold on;plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
annotation('arrow',[0.645 0.63],[0.655 0.74]);
text(0.5,1.2,'$a_1=2,a_2=3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% a1=2;a2=1;
a1=2;a2=1;
a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i))-a_2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(144);plot(t,y0,'k--','LineWidth',1.5)
hold on;plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
annotation('arrow',[0.805 0.79],[0.68 0.75]);
text(0.5,1.2,'$a_1=2,a_2=1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

lgd = legend('$a_1=2,a_2=2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5);
lgd.NumColumns = 1;
lgd.Position = [0.825 0.95 0 0];  % 左右 上下 宽度 高度

sgtitle('$\ddot x=-(a_1+k_1)(x-v_0)-(a_2+k_2) \dot x \quad (k_1=2,k_2=2)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-3
图1-4-3

图1-4-3 Provided by 张聪玮 @2022-04-14
%对象(1.4.4)——ddx=-(a_1+k_1)(x-v_0)-(a_2+k_2) dx
clc,clear,clf
h=0.005;T=5;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);
a1=2;a2=2;k2=0;

%% k1=0;
k1=0;a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.4)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i))-a_2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(131);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.1,'$k_1=0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1=3;
k1=3;a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i))-a_2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(132);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.1,'$k_1=3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1=6;
k1=6;a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i))-a_2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(133);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.1,'$k_1=6$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)



sgtitle('$\ddot x=-(a_1+k_1)(x-v_0)-(a_2+k_2) \dot x \quad (a_1=2,a_2=2,k_2=0)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-4
图1-4-4

图1-4-4 Provided by 张聪玮 @2022-04-14
%对象(1.4.8)——ddx=-(a_1+k_1)(x-v_0*tran(T0,t))-a_2*dx
clc,clear,clf
h=0.001;T=5;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);
a1=2;a2=2;k2=0;
%% k1=800,T0=2
k1=800;T0=2;
a_1=a1+k1;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.8)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(141);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,1.1,'$k_1=800,T_0=2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1=400,T0=2
k1=400;T0=2;
a_1=a1+k1;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.8)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(142);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,1.1,'$k_1=400,T_0=2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1=800,T0=1
k1=800;T0=1;
a_1=a1+k1;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.8)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(143);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,1.1,'$k_1=800,T_0=1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1=400,T0=1
k1=400;T0=1;
a_1=a1+k1;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.8)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(144);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,1.1,'$k_1=400,T_0=1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)


sgtitle('$\ddot x=-(a_1+k_1)(x-v_0 trns(T_0,t))-(a_2+k_2) \dot x \quad (a_1=2,a_2=2,k_2=0)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-5
图1-4-5

图1-4-5 Provided by 张聪玮 @2022-04-14
%对象(1.4.8)——ddx=-(a_1+k_1)(x-v_0*tran(T0,t))-a_2*dx
clc,clear,clf
h=0.001;T=5;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);
a1=2;k1=600;k2=0;T0=1;a_1=a1+k1;

%% a2=2
a2=2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.8)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(141);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.1,'$a_2=2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% a2=10
a2=10;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.8)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(142);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.1,'$a_2=10$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% a2=30
a2=30;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.8)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(143);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.1,'$a_2=30$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% a2=50
a2=50;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.8)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a2*x2(i));
    y(i+1)=x1(i+1);
end
subplot(144);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,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.1,'$a_2=50$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)


sgtitle('$\ddot x=-(a_1+k_1)(x-v_0 trns(T_0,t))-(a_2+k_2) \dot x \quad (a_1=2,T_0=1,k_1=600,k_2=0)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-6
图1-4-6

图1-4-6 Provided by 张聪玮 @2022-04-14
%对象(1.4.10)——ddx=-(a_1+k_1)(x-v_0*tran(T0,t))-a_2*(dx-v0*dtrns(T0,t))
clc,clear,clf
h=0.001;T=2;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);
a1=2;a2=2;T0=0.5;

%% k1=10,k2=12
k1=10;k2=12;
a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.10)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a_2*(x2(i)-v0(i).*dtrns(T0,t(i))));
    y(i+1)=x1(i+1);
end
subplot(141);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,2,-0.2,1.2]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,1080,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,-0.1,'$k_1=10,k_2=12$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1=10,k2=120
k1=10;k2=120;
a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.10)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a_2*(x2(i)-v0(i).*dtrns(T0,t(i))));
    y(i+1)=x1(i+1);
end
subplot(142);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,2,-0.2,1.2]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,1080,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.15,-0.1,'$k_1=10,k_2=120$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1=1000,k2=120
k1=1000;k2=120;
a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.10)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a_2*(x2(i)-v0(i).*dtrns(T0,t(i))));
    y(i+1)=x1(i+1);
end
subplot(143);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,2,-0.2,1.2]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,1080,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0,-0.1,'$k_1=1000,k_2=120$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% k1=1000,k2=12
k1=1000;k2=12;
a_1=a1+k1;a_2=a2+k2;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i); %公式(1.4.10)
    x2(i+1)=x2(i)+h*(-a_1*(x1(i)-v0(i).*trns(T0,t(i)))-a_2*(x2(i)-v0(i).*dtrns(T0,t(i))));
    y(i+1)=x1(i+1);
end
subplot(144);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,2,-0.2,1.2]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[100,162,1080,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.05,-0.1,'$k_1=1000,k_2=12$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

sgtitle('$\ddot x=-(a_1+k_1)(x-v_0 trns(T_0,t))-(a_2+k_2) (\dot x-v_0 dtrns(T_0,t)) \quad (a_1=2,a_2=2,T_0=0.5)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

1.4节 7-13

1.4节

图1-4-7
图1-4-7

图1-4-7 Provided by 张聪玮 @2022-04-14
clc,clear,clf
h=0.001;T=4;N=T/h;
n=1:N;t=n*h;
vv1=zeros(1,N);vv2=zeros(1,N);vv3=zeros(1,N);vv4=zeros(1,N);
v0=1;T0=3;

for i=1:N-1
    %% 第一种形式
    if t(i)<=T0
        vv1(i)=v0/T0;
    else
        vv1(i)=0;
    end

    %% 第二种形式
    if t(i)<=T0/2
        vv2(i)=4*v0*t(i)/T0^2;
    elseif (T0/2<t(i)) && (t(i)<=T0)
        vv2(i)=-4*v0*t(i)/T0^2+4*v0/T0;
    else
        vv2(i)=0;
    end

    %% 第三种形式
    if t(i)<=T0
        vv3(i)=-6*v0*t(i).^2/T0^3+6*v0*t(i)/T0^2;
    else
        vv3(i)=0;
    end

    %% 第四种形式
    if t(i)<=T0
        vv4(i)=30*v0*t(i).^4/T0^5-60*v0*t(i).^3/T0^4+30*v0*t(i).^2/T0^3;
    else
        vv4(i)=0;
    end
end

subplot(141);plot(t,vv1,'k','LineWidth',1.5)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$v_2(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,4,0,1]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:4]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,0.92,'$t \le T_0$:','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(0.5,0.8,'$v_2(t)=v_0/T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
% text(0.2,0.68,'$t > T_0$:','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
% text(0.5,0.56,'$v_2(t)=0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)

subplot(142);plot(t,vv2,'k','LineWidth',1.5)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$v_2(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,4,0,1.4]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:4]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.2:1.4]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,1.3,'$t \le T_0/2$:','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(0.45,1.15,'$v_2(t)=4v_0t/T_0^2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(0.2,1,'$T_0/2 < t \le T_0$:','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(0.45,0.85,'$v_2(t)=-4v_0t/T_0^2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(2.1,0.7,'$+4v_0/T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)

subplot(143);plot(t,vv3,'k','LineWidth',1.5)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$v_2(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,4,0,1]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:4]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,0.92,'$t \le T_0$:','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(0.3,0.8,'$v_2(t)=-6v_0t^2/T_0^3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(1.9,0.68,'$+6v_0t/T_0^2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)


subplot(144);plot(t,vv4,'k','LineWidth',1.5)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$v_2(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,4,0,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:4]); %设置要显示坐标刻度
set(gca,'YTick',[0:0.2:1.2]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,1.12,'$t \le T_0$:','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(0.3,0.97,'$v_2(t)=30v_0t^4/T_0^5$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(1.55,0.82,'$-60v_0t^3/T_0^4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)
text(1.55,0.67,'$+30v_0t^2/T_0^3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5)

sgtitle('$v_2(t)=0 \quad (t>T_0) ,\quad v_0=1,T_0=3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-8
图1-4-8

图1-4-8 Provided by 张聪玮 @2022-04-14
clc,clear,clf
h=0.001;T=5;N=T/h;
n=1:N;t=n*h;
vv1=zeros(1,N);vv2=zeros(1,N);vv3=zeros(1,N);vv4=zeros(1,N);
v0=2;T0=4;

for i=1:N-1
    %% 第一种形式
    if t(i)<=T0/2
        vv1(i)=4*v0/T0^2;
    elseif (T0/2<t(i)) && (t(i)<=T0)
        vv1(i)=-4*v0/T0^2;
    else
        vv1(i)=0;
    end

    %% 第二种形式
    if t(i)<=T0/4
        vv2(i)=8*v0*t(i)/T0^2;
    elseif (T0/4<t(i)) && (t(i)<=3/4*T0)
        vv2(i)=-8*v0*t(i)/T0^2+4*v0/T0;
    elseif (3/4*T0<t(i)) && (t(i)<=T0)
        vv2(i)=8*v0*(t(i)-T0/2)/T0^2-4*v0/T0;
    else
        vv2(i)=0;
    end

    %% 第三种形式
    if t(i)<=T0/2
        vv3(i)=-24*v0*t(i).^2/T0^3+12*v0*t(i)/T0^2;
    elseif (T0/2<t(i)) && (t(i)<=T0)
        vv3(i)=24*v0*(t(i)-T0/2).^2/T0^3-12*v0*(t(i)-T0/2)/T0^2;
    else
        vv3(i)=0;
    end

    %% 第四种形式
    if t(i)<=T0/2
        vv4(i)=480*v0*t(i).^4/T0^5-480*v0*t(i).^3/T0^4+120*v0*t(i).^2/T0^3;
    elseif (T0/2<t(i)) && (t(i)<=T0)
        vv4(i)=-480*v0*(t(i)-T0/2).^4/T0^5+480*v0*(t(i)-T0/2).^3/T0^4-120*v0*(t(i)-T0/2).^2/T0^3;
    else
        vv4(i)=0;
    end
end

subplot(141);plot(t,vv1,'k','LineWidth',1.5)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$v_3(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:5]); %设置要显示坐标刻度
set(gca,'YTick',[-1:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线

subplot(142);plot(t,vv2,'k','LineWidth',1.5)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
axis([0,5,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:5]); %设置要显示坐标刻度
set(gca,'YTick',[-1:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线

subplot(143);plot(t,vv3,'k','LineWidth',1.5)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
axis([0,5,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:5]); %设置要显示坐标刻度
set(gca,'YTick',[-1:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线


subplot(144);plot(t,vv4,'k','LineWidth',1.5)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
axis([0,5,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:5]); %设置要显示坐标刻度
set(gca,'YTick',[-1:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线

sgtitle('$v_0=2,T_0=4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-9
图1-4-9

图1-4-9 Provided by 张聪玮 @2022-04-14
clc,clear,clf
h=0.001;T=5;N=T/h;
n=1:N;t=n*h;
v1=zeros(1,N);v2=zeros(1,N);v3=zeros(1,N);v4=zeros(1,N);
v0=2;T0=4;

for i=2:N-1
    %% 过渡过程的加加速度函数v4(t)
    if t(i)<=T0/4
        v4(i)=32*v0/T0^3;
    elseif (T0/4<t(i)) && (t(i)<=3/4*T0)
        v4(i)=-32*v0/T0^3;
    elseif (3/4*T0<t(i)) && (t(i)<=T0)
        v4(i)=32*v0/T0^3;
    else
        v4(i)=0;
    end

    %% 过渡过程的加速度函数v3(t)
    v3(i)=v3(i-1)+h*v4(i);

    %% 过渡过程的速度函数v2(t)
    v2(i)=v2(i-1)+h*v3(i);

    %% 安排的过渡过程
    v1(i)=v1(i-1)+h*v2(i);

end
v1(N)=v1(N-1);

subplot(141);plot(t,v4,'k','LineWidth',1.5)
hold on;plot([0,5],[0,0],'k-.','LineWidth',1)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$v_4(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:5]); %设置要显示坐标刻度
set(gca,'YTick',[-1:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.7,'$v_4(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(142);plot(t,v3,'k','LineWidth',1.5)
hold on;plot([0,5],[0,0],'k-.','LineWidth',1)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$v_3(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:5]); %设置要显示坐标刻度
set(gca,'YTick',[-1:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.7,'$v_3(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(143);plot(t,v2,'k','LineWidth',1.5)
hold on;plot([0,5],[0,0],'k-.','LineWidth',1)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$v_2(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:5]); %设置要显示坐标刻度
set(gca,'YTick',[-1:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.4,0.7,'$v_2(t)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(144);plot(t,v1/2,'k','LineWidth',1.5)
hold on;plot([0,5],[0,0],'k-.','LineWidth',1)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$v_1(t)/2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:5]); %设置要显示坐标刻度
set(gca,'YTick',[-1:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,980,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(2.9,0.7,'$$\frac{v_1(t)}{2}$$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

sgtitle('$v_0=2,T_0=4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-10
图1-4-10

图1-4-10 Provided by 张聪玮 @2022-04-14
clc,clear,clf
h=0.01;T=10;N=T/h;n=1:N;t=n*h;
u1=zeros(1,N);u2=zeros(1,N);u3=zeros(1,N);u4=zeros(1,N);
T0=8;
for i=1:N-1
    u1(i)=s(t(i),T0);
    u2(i)=-s(t(i)-T0/2,T0/2);
    u3(i)=s(t(i)-T0/4,T0).*s(t(i)-3/4*T0,T0/4);
    u4(i)=-s(t(i)-(2-sqrt(2))/4*T0,T0).*s(t(i)-2/4*T0,T0/2).*s(t(i)-(2+sqrt(2))/4*T0,T0);
end
subplot(411);plot(t,u1,'k','LineWidth',1.5)
hold on;plot([8,8],[-1.2,1.2],'k:','LineWidth',0.8)
hold on;plot([0,10],[0,0],'k-.','LineWidth',1)
ylabel('$u_1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:11:10]); %设置要显示坐标刻度
set(gca,'YTick',[-1:1:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
% text(4.5,-0.5,'$u_1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(8,-2,'$T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(412);plot(t,u2,'k','LineWidth',1.5)
hold on;plot([8,8],[-1.2,1.2],'k:','LineWidth',0.8)
hold on;plot([0,10],[0,0],'k-.','LineWidth',1)
ylabel('$u_2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:11:10]); %设置要显示坐标刻度
set(gca,'YTick',[-1:1:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
% text(4.5,-0.1,'$u_2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(8,-2,'$T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(413);plot(t,u3,'k','LineWidth',1.5)
hold on;plot([8,8],[-1.2,1.2],'k:','LineWidth',0.8)
hold on;plot([0,10],[0,0],'k-.','LineWidth',1)
ylabel('$u_3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:11:10]); %设置要显示坐标刻度
set(gca,'YTick',[-1:1:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
% text(4.5,-0.1,'$u_3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(8,-2,'$T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(414);plot(t,u4,'k','LineWidth',1.5)
hold on;plot([8,8],[-1.2,1.2],'k:','LineWidth',0.8)
hold on;plot([0,10],[0,0],'k-.','LineWidth',1)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$u_4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:11:10]); %设置要显示坐标刻度
set(gca,'YTick',[-1:1:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
% text(4.5,-0.1,'$u_4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(8,-2,'$T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-11
图1-4-11

图1-4-11 Provided by 张聪玮 @2022-04-14
clc,clear,clf
h=0.0001;T=10;
N=T/h;n=1:N;t=n*h;
T0=8;
u1=zeros(1,N);Iu1=zeros(1,N);
u2=zeros(1,N);Iu2=zeros(1,N);I2u2=zeros(1,N);
u3=zeros(1,N);Iu3=zeros(1,N);I2u3=zeros(1,N);I3u3=zeros(1,N);
u4=zeros(1,N);Iu4=zeros(1,N);I2u4=zeros(1,N);I3u4=zeros(1,N);I4u4=zeros(1,N);

for i=2:N-1
    %% 一阶
    u1(i)=s(t(i),T0); %过渡过程的速度信号
    Iu1(i)=Iu1(i-1)+h*u1(i); %安排的过渡过程

    %% 二阶
    u2(i)=-s(t(i)-T0/2,T0/2); %过渡过程的加速度信号
    Iu2(i)=Iu2(i-1)+h*u2(i); %过渡过程的速度信号
    I2u2(i)=I2u2(i-1)+h*Iu2(i); %安排的过渡过程

    %% 三阶
    u3(i)=s(t(i)-T0/4,T0).*s(t(i)-3/4*T0,T0/4); %过渡过程的加加速度信号
    Iu3(i)=Iu3(i-1)+h*u3(i); %过渡过程的加速度信号
    I2u3(i)=I2u3(i-1)+h*Iu3(i); %过渡过程的速度信号
    I3u3(i)=I3u3(i-1)+h*I2u3(i); %安排的过渡过程

    %% 四阶
    u4(i)=-s(t(i)-(2-sqrt(2))/4*T0,T0).*s(t(i)-2/4*T0,T0/2).*s(t(i)-(2+sqrt(2))/4*T0,T0); %过渡过程的加加加速度信号
    Iu4(i)=Iu4(i-1)+h*u4(i); %过渡过程的加加速度信号
    I2u4(i)=I2u4(i-1)+h*Iu4(i); %过渡过程的加速度信号
    I3u4(i)=I3u4(i-1)+h*I2u4(i); %过渡过程的速度信号
    I4u4(i)=I4u4(i-1)+h*I3u4(i); %安排的过渡过程
end
Iu1(N)=Iu1(N-1);
Iu2(N)=Iu2(N-1);I2u2(N)=I2u2(N-1);n1=max(Iu2);
Iu3(N)=Iu3(N-1);I2u3(N)=I2u3(N-1);I3u3(N)=I3u3(N-1);n2=max(Iu3);n3=max(I2u3);
Iu4(N)=Iu4(N-1);I2u4(N)=I2u4(N-1);I3u4(N)=I3u4(N-1);I4u4(N)=I4u4(N-1);n4=max(Iu4);n5=max(I2u4);n6=max(I3u4);

subplot(411);plot(t,u1,'k',t,Iu1/Iu1(N),'k','LineWidth',1.5)
hold on;plot([8,8],[-1.2,1.2],'k:','LineWidth',0.8)
hold on;plot([0,10],[0,0],'k-.','LineWidth',1)
% ylabel('$u_1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:11:10]); %设置要显示坐标刻度
set(gca,'YTick',[-1:1:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
% text(4.5,-0.5,'$u_1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(8,-2,'$T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(412);plot(t,u2,'k',t,Iu2/n1,'k',t,I2u2/I2u2(N),'k','LineWidth',1.5)
hold on;plot([8,8],[-1.2,1.2],'k:','LineWidth',0.8)
hold on;plot([0,10],[0,0],'k-.','LineWidth',1)
% ylabel('$u_2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:11:10]); %设置要显示坐标刻度
set(gca,'YTick',[-1:1:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
% text(4.5,-0.1,'$u_2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(8,-2,'$T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(413);plot(t,u3,'k',t,Iu3/n2,'k',t,I2u3/n3,'k',t,I3u3/I3u3(N),'k','LineWidth',1.5)
hold on;plot([8,8],[-1.2,1.2],'k:','LineWidth',0.8)
hold on;plot([0,10],[0,0],'k-.','LineWidth',1)
% ylabel('$u_3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:11:10]); %设置要显示坐标刻度
set(gca,'YTick',[-1:1:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
% text(4.5,-0.1,'$u_3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(8,-2,'$T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

subplot(414);plot(t,u4,'k',t,Iu4/n4,'k',t,I2u4/n5,'k',t,I3u4/n6,'k',t,I4u4/I4u4(N),'k','LineWidth',1.5)
hold on;plot([8,8],[-1.2,1.2],'k:','LineWidth',0.8)
hold on;plot([0,10],[0,0],'k-.','LineWidth',1)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$u_4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,-1.5,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:11:10]); %设置要显示坐标刻度
set(gca,'YTick',[-1:1:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
% text(4.5,-0.1,'$u_4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(8,-2,'$T_0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-4-12
图1-4-12

图1-4-12 Provided by 张聪玮 @2022-04-14
clc,clear,clf
h=0.0001;T=7;
N=T/h;n=1:N;t=n*h;
T0=5;
u5=zeros(1,N);Iu5=zeros(1,N);I2u5=zeros(1,N);I3u5=zeros(1,N);I4u5=zeros(1,N);I5u5=zeros(1,N);

for i=2:N-1
    u5(i)=s(t(i)-0.095475*T0,T0).*s(t(i)-0.345475*T0,T0).*s(t(i)-0.654525*T0,T0).*s(t(i)-0.904525*T0,T0); %过渡过程的加加加加速度信号
    Iu5(i)=Iu5(i-1)+h*u5(i); %过渡过程的加加加速度信号
    I2u5(i)=I2u5(i-1)+h*Iu5(i); %过渡过程的加加速度信号
    I3u5(i)=I3u5(i-1)+h*I2u5(i); %过渡过程的加速度信号
    I4u5(i)=I4u5(i-1)+h*I3u5(i); %过渡过程的速度信号
    I5u5(i)=I5u5(i-1)+h*I4u5(i); %安排的过渡过程
end
Iu5(N)=Iu5(N-1);I2u5(N)=I2u5(N-1);I3u5(N)=I3u5(N-1);I4u5(N)=I4u5(N-1);I5u5(N)=I5u5(N-1);
n1=max(Iu5);n2=max(I2u5);n3=max(I3u5);n4=max(I4u5);

plot(t,u5,'k',t,Iu5/n1,'k',t,I2u5/n2,'k',t,I3u5/n3,'k',t,I4u5/n4,'k',t,I5u5/I5u5(N),'k','LineWidth',1.5)
hold on;plot([0,7],[0,0],'k-.','LineWidth',1)
xlabel('$t$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
axis([0,7,-1.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:1:7]); %设置要显示坐标刻度
set(gca,'YTick',[-1:0.2:1]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线

图1-4-13
图1-4-13

图1-4-13 Provided by 张聪玮 @2022-04-14
clc,clear,clf
h=0.001;T=10;N=T/h;
n=1:N;t=n*h;
v0=1;r=2;
v1=zeros(1,N);v2=zeros(1,N);v3=zeros(1,N);v4=zeros(1,N);f=zeros(1,N);

for i=1:N-1
    f(i)=-r*(r*(r*(r*(v1(i)-v0)+4*v2(i))+6*v3(i))+4*v4(i));
    v1(i+1)=v1(i)+h*v2(i);
    v2(i+1)=v2(i)+h*v3(i);
    v3(i+1)=v3(i)+h*v4(i);
    v4(i+1)=v4(i)+h*f(i);

end
t(N)=N*h;
plot(t,v1,'k','LineWidth',2)
hold on;plot(t,v2,'k',t,v3,'k-.',t,v4,'k:',t,f/4,'k--','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$v_i (i=1,2,3,4) , f/4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,10,-1.5,2]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
legend('$v_1$','$v_2$','$v_3$','$v_4$','$f/4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',13.5); %图例
text(4.6,-0.9,'$r=2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)


title('$y=r^4v_0/(s+r)^4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

1.5节

1.5节

图1-5-1
图1-5-1

图1-5-1 Provided by 张聪玮 @2022-04-14
%一阶系统阶跃响应速度与r的关系(成正比)
clc,clear,clf
h=0.001;T=6;N=T/h;
n=0:N;t=n*h;
% v0=ones(1,N);
t0 = 0; % t0表示阶跃信号突变的时刻
v0 = stepfun(t,t0); % 输入单位阶跃信号
x1=zeros(1,N);
%% r=1
r=1;
for i=1:N
    x1(i+1)=x1(i)+h*(-r*(x1(i)-v0(i)));
    y(i+1)=x1(i+1);
end
subplot(211);plot(t,y,'k','LineWidth',1.5)
% xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,6,0,1]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,480,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(2.5,0.25,'$r=1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% r=5
r=5;
for i=1:N
    x1(i+1)=x1(i)+h*(-r*(x1(i)-v0(i)));
    y(i+1)=x1(i+1);
end
subplot(212);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,6,0,1]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,480,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(2.5,0.25,'$r=5$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)


sgtitle('$\dot x=-r(x-v_0)$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-5-2
图1-5-2

图1-5-2 Provided by 张聪玮 @2022-04-14
%二阶系统阶跃响应速度与r的关系(成正比)
clc,clear,clf
h=0.001;T=10;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);
%% r=1,xi=0.4
r=1;xi=0.4;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*xi*x2(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,10,0,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(2.5,0.25,'$r=1,\xi=0.4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% r=1,xi=0.7
r=1;xi=0.7;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*xi*x2(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,10,0,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(2.5,0.25,'$r=1,\xi=0.7$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% r=1,xi=1.0
r=1;xi=1.0;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*xi*x2(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,10,0,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(2.5,0.25,'$r=1,\xi=1.0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% r=3,xi=0.4
r=3;xi=0.4;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*xi*x2(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,10,0,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(2.5,0.25,'$r=3,\xi=0.4$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% r=3,xi=0.7
r=3;xi=0.7;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*xi*x2(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,10,0,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(2.5,0.25,'$r=3,\xi=0.7$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% r=3,xi=1.0
r=3;xi=1.0;
for i=1:N
    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-r^2*(x1(i)-v0(i))-2*r*xi*x2(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,10,0,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(2.5,0.25,'$r=3,\xi=1.0$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

sgtitle('$\ddot x=-r^2(x-u)-2r\xi \dot x$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-5-3
图1-5-3

图1-5-3 Provided by 张聪玮 @2022-04-14
%三阶系统阶跃响应速度与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)

图1-5-4
图1-5-4

图1-5-4 Provided by 张聪玮 @2022-04-14
%时间尺度
clc,clear,clf
h=0.001;T=5;N=T/h;
n=1:N;t=n*h;
v0=1;
a2=1;
x1=zeros(1,N);x2=zeros(1,N);
e=zeros(1,N);De=zeros(1,N);e0=zeros(1,N); %误差,误差的微分,误差的积分
e(1)=v0(1);De(1)=0;e0(1)=0;

%% 第一组参数
a1=1;k0=0.9;k1=2.0;k2=1.6;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(221);plot(t,y,'k','LineWidth',1.5)
% xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.8,0.6,'$a_1=1,a_2=1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(0.85,0.25,'$k_0=0.9,k_1=2,k_2=1.6$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% 第二组参数
a1=4;k0=7.2;k1=8.0;k2=4.3;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(222);plot(t,y,'k','LineWidth',1.5)
% xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.6,'$a_1=4,a_2=1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(0.7,0.25,'$k_0=7.2,k_1=8,k_2=4.3$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% 第三组参数
a1=9;k0=24.3;k1=18.0;k2=7.0;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(223);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.6,'$a_1=9,a_2=1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(0.5,0.25,'$k_0=24.3,k_1=18,k_2=7$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% 第四组参数
a1=16;k0=57.6;k1=32;k2=9.6;
for i=2:N-1
    e(i)=v0-x1(i); %误差
    De(i)=(e(i)-e(i-1))/h; %误差的微分(差分)
    e0(i)=e0(i-1)+h*e(i); %误差的积分
    u(i+1)=k1*e(i)+k0*e0(i)+k2*De(i);

    x1(i+1)=x1(i)+h*x2(i);
    x2(i+1)=x2(i)+h*(-a1*x1(i)-a2*x2(i)+u(i+1));
    y(i+1)=x1(i+1);
end
t(N)=N*h;
subplot(224);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,0,1.4]); % 设置坐标轴上下限
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,410]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1.5,0.6,'$a_1=16,a_2=1$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)
text(0.35,0.25,'$k_0=57.6,k_1=32,k_2=9.6$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)


% sgtitle('$\ddot x=-a_1 (x-u)-a_2 \dot x$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-5-5
图1-5-5

图1-5-5 Provided by 张聪玮 @2022-04-14
%二阶对象
clc,clear,clf
h=0.001;T=5;N=T/h;
n=1:N;t=n*h;
t0=0; %t0表示阶跃信号突变的时刻
v0=stepfun(t,t0); %输入单位阶跃信号
a1=1;a2=1;T0=2;
e0=zeros(1,N);e1=zeros(1,N);e2=zeros(1,N);
v=zeros(1,N);dv=zeros(1,N);ddv=zeros(1,N);w=zeros(1,N);

%% 第一组参数
k0=50;k1=50;k2=50;
for i=2:N-1
    v(i)=v0(i).*trns(T0,t(i));
    dv(i)=v0(i).*dtrns(T0,t(i));
    ddv(i)=v0(i).*ddtrns(T0,t(i));
    w(i)=ddv(i)+a2*dv(i)+a1*v(i);

    e0(i+1)=e0(i)+h*e1(i);
    e1(i+1)=e1(i)+h*e2(i);
    e2(i+1)=e2(i)+h*(-k0*e0(i)-(a1+k1)*e1(i)-(a2+k2)*e2(i)+w(i));
    y(i+1)=v(i)-e1(i+1);
end
t(N)=N*h;
subplot(131);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,-0.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:5:5]); %设置要显示坐标刻度
set(gca,'YTick',[-0.2:0.2:1.2]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,-0.1,'$k_0=k_1=k_2=50$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% 第二组参数
k0=30;k1=30;k2=30;
for i=2:N-1
    v(i)=v0(i).*trns(T0,t(i));
    dv(i)=v0(i).*dtrns(T0,t(i));
    ddv(i)=v0(i).*ddtrns(T0,t(i));
    w(i)=ddv(i)+a2*dv(i)+a1*v(i);

    e0(i+1)=e0(i)+h*e1(i);
    e1(i+1)=e1(i)+h*e2(i);
    e2(i+1)=e2(i)+h*(-k0*e0(i)-(a1+k1)*e1(i)-(a2+k2)*e2(i)+w(i));
    y(i+1)=v(i)-e1(i+1);
end
t(N)=N*h;
subplot(132);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,-0.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:5:5]); %设置要显示坐标刻度
set(gca,'YTick',[-0.2:0.2:1.2]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,-0.1,'$k_0=k_1=k_2=30$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% 第三组参数
k0=70;k1=70;k2=70;
for i=2:N-1
    v(i)=v0(i).*trns(T0,t(i));
    dv(i)=v0(i).*dtrns(T0,t(i));
    ddv(i)=v0(i).*ddtrns(T0,t(i));
    w(i)=ddv(i)+a2*dv(i)+a1*v(i);

    e0(i+1)=e0(i)+h*e1(i);
    e1(i+1)=e1(i)+h*e2(i);
    e2(i+1)=e2(i)+h*(-k0*e0(i)-(a1+k1)*e1(i)-(a2+k2)*e2(i)+w(i));
    y(i+1)=v(i)-e1(i+1);
end
t(N)=N*h;
subplot(133);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,5,-0.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:5:5]); %设置要显示坐标刻度
set(gca,'YTick',[-0.2:0.2:1.2]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.2,-0.1,'$k_0=k_1=k_2=70$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)


sgtitle('$a_1=1,a_2=1,T_0=2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

图1-5-6
图1-5-6

图1-5-6 Provided by 张聪玮 @2022-04-14
%二阶对象
clc,clear,clf
h=0.001;T=6;N=T/h;
n=1:N;t=n*h;
t0=0; %t0表示阶跃信号突变的时刻
v0=stepfun(t,t0); %输入单位阶跃信号
k0=4472;k1=1000;k2=223.6;
e0=zeros(1,N);e1=zeros(1,N);e2=zeros(1,N);
v=zeros(1,N);dv=zeros(1,N);ddv=zeros(1,N);w=zeros(1,N);
a1=20;a2=1;

%% 第一组对象参数
T0=2;
for i=2:N-1
    v(i)=v0(i).*trns(T0,t(i));
    dv(i)=v0(i).*dtrns(T0,t(i));
    ddv(i)=v0(i).*ddtrns(T0,t(i));
    w(i)=ddv(i)+a2*dv(i)+a1*v(i);

    e0(i+1)=e0(i)+h*e1(i);
    e1(i+1)=e1(i)+h*e2(i);
    e2(i+1)=e2(i)+h*(-k0*e0(i)-(a1+k1)*e1(i)-(a2+k2)*e2(i)+w(i));
    y(i+1)=v(i)-e1(i+1);
end
t(N)=N*h;
subplot(121);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,6,-0.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:2:6]); %设置要显示坐标刻度
set(gca,'YTick',[-0.2:0.2:1.2]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(1,-0.1,'$a_1=20,a_2=1,T_0=2$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)

%% 第二组对象参数
T0=0.447;
for i=2:N-1
    v(i)=v0(i).*trns(T0,t(i));
    dv(i)=v0(i).*dtrns(T0,t(i));
    ddv(i)=v0(i).*ddtrns(T0,t(i));
    w(i)=ddv(i)+a2*dv(i)+a1*v(i);

    e0(i+1)=e0(i)+h*e1(i);
    e1(i+1)=e1(i)+h*e2(i);
    e2(i+1)=e2(i)+h*(-k0*e0(i)-(a1+k1)*e1(i)-(a2+k2)*e2(i)+w(i));
    y(i+1)=v(i)-e1(i+1);
end
t(N)=N*h;
subplot(122);plot(t,y,'k','LineWidth',1.5)
xlabel('$t/s$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15); % 标注坐标轴
% ylabel('$y$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15);
axis([0,6,-0.2,1.2]); % 设置坐标轴上下限
set(gca,'XTick',[0:2:6]); %设置要显示坐标刻度
set(gca,'YTick',[-0.2:0.2:1.2]); %设置要显示坐标刻度
axis_h=gca;  % 当前轴的句柄
set(axis_h,'Fontname','Times New Roman','Fontsize',15,'LineWidth',0.8)
set(gcf,'Position',[200,162,780,350]); % 设置图片大小
grid on;set(gca,'GridLineStyle',':','GridColor','k','GridAlpha',1); % 设置网格线为虚线
text(0.4,-0.1,'$a_1=20,a_2=1,T_0=0.447$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)



sgtitle('$k_0=4472,k_1=1000,k_2=223.6$','Interpreter','Latex','Fontname','Times New Roman','Fontsize',15)