clear;
clc;
close all;
t = 0:0.01:10;
wn = 5;
x0 = 1;
v0 = 5;
t1 = tiledlayout(3, 1, 'TileSpacing', 'Compact');
u = 1.1;
s1 = (-u+sqrt(u^2-1)) * wn;
s2 = (-u-sqrt(u^2-1)) * wn;
X1 = (v0-s2 * x0)/(s1-s2);
X2 = (v0-s1 * x0)/(s2-s1);
x1 = X1 * exp(s1 * t)+X2 * exp(s2 * t);nexttile;
plot(t, x1);
grid on;
ylabel('x_{1}', 'FontName', 'Times New Roman', 'FontSize', 10');
u = 0.1;
wd = sqrt(1-u^2) * wn;
X = sqrt(x0^2+(v0+u * wn * x0)^2/wd^2);
phi = atan((v0+u * wn * x0)/(x0 * wd));
x2 = exp(-u * wn * t) * X .* cos(wd * t-phi);nexttile;
plot(t, x2)
grid on;
ylabel('x_{2}', 'FontName', 'Times New Roman', 'FontSize', 10');
u = 0;
X = sqrt(x0^2+(v0/wn)^2);
phi = atan(v0/(x0 * wd));
x3 = X * cos(wd * t-phi);nexttile;
plot(t, x3)
grid on;
ylabel('x_{3}', 'FontName', 'Times New Roman', 'FontSize', 10');
title(t1, '不同阻尼比情况下的自由振动位移时程曲线', 'FontName', '黑体', 'FontSize', 10)