Tp = 64 1000; 观察时间 Tp = 64 微秒 Fs = 1000; T = 1 Fs;Fs = 1000;T = 1 Fs; 产生 M 长采样序列 xnM = roundTp Fs; 修正采样点数为最接近的整数n = 0M-1;A = 444128;alph = pi 50 2^05;omega = pi 50 2^05;xnt = A exp-alph

抱歉,我之前理解有误。你希望将前面六个图和后面六个图分别显示在两个窗口中。

以下是修改后的代码,以实现这个目标:

Tp = 64 / 1000;  % 观察时间 Tp = 64 微秒

% Fs = 1000; T = 1 / Fs;
Fs = 1000;
T = 1 / Fs;

% 产生 M 长采样序列 x(n)
M = round(Tp * Fs);  % 修正采样点数为最接近的整数
n = 0:M-1;
A = 444.128;
alph = pi * 50 * 2^0.5;
omega = pi * 50 * 2^0.5;
xnt = A * exp(-alph * n * T) .* sin(omega * n * T);
Xk = T * fft(xnt, M);  % M 点 FFT[(xnt)]

figure('Name', 'Fs = 1000Hz');
subplot(3, 2, 1);
plot(n, xnt);
xlabel('n');
ylabel('xa(nT)');
title('(a) Fs = 1000Hz');
grid on;

k = 0:M-1;
fk = k / Tp;
subplot(3, 2, 2);
plot(fk, abs(Xk));
xlabel('f(Hz)');
ylabel('Amplitude');
title('(a) T*FT[xa(nT)], Fs = 1000Hz');
axis([0, Fs, 0, 1.2 * max(abs(Xk))]);
grid on;

% Fs = 300Hz 的情况
Fs = 300;
T = 1 / Fs;

M = round(Tp * Fs);  % 修正采样点数为最接近的整数
n = 0:M-1;
xnt = A * exp(-alph * n * T) .* sin(omega * n * T);
Xk = T * fft(xnt, M);  % M 点 FFT[(xnt)]

figure('Name', 'Fs = 300Hz');
subplot(3, 2, 1);
plot(n, xnt);
xlabel('n');
ylabel('xa(nT)');
title('(a) Fs = 300Hz');
grid on;

k = 0:M-1;
fk = k / Tp;
subplot(3, 2, 2);
plot(fk, abs(Xk));
xlabel('f(Hz)');
ylabel('Amplitude');
title('(a) T*FT[xa(nT)], Fs = 300Hz');
axis([0, Fs, 0, 1.2 * max(abs(Xk))]);
grid on;

% Fs = 200Hz 的情况
Fs = 200;
T = 1 / Fs;

M = round(Tp * Fs);  % 修正采样点数为最接近的整数
n = 0:M-1;
xnt = A * exp(-alph * n * T) .* sin(omega * n * T);
Xk = T * fft(xnt, M);  % M 点 FFT[(xnt)]

figure('Name', 'Fs = 200Hz');
subplot(3, 2, 1);
plot(n, xnt);
xlabel('n');
ylabel('xa(nT)');
title('(a) Fs = 200Hz');
grid on;

k = 0:M-1;
fk = k / Tp;
subplot(3, 2, 2);
plot(fk, abs(Xk));
xlabel('f(Hz)');
ylabel('Amplitude');
title('(a) T*FT[xa(nT)], Fs = 200Hz');
axis([0, Fs, 0, 1.2 * max(abs(Xk))]);
grid on;

%=========2 频域采样理论的验证程序清单=========
M = 27;
N = 32;
n = 0:M;

% 产生 M 长三角波序列 x(n)
xa = 0:floor(M/2);
xb = ceil(M/2)-1:-1:0;
xn = [xa, xb];

Xk = fft(xn, 1024);  % 1024 点 FFT[x(n)],用于近似序列 x(n) 的 TF
X32k = fft(xn, 32);  % 32 点 FFT[x(n)]
x32n = ifft(X32k);  % 32 点 IFFT[X32(k)] 得到 x32(n)
X16k = X32k(1:2:N);  % 隔点抽取 X32k 得到 X16(K)
x16n = ifft(X16k, N/2);  % 16 点 IFFT[X16(k)] 得到 x16(n)

figure('Name', '2 频域采样理论的验证');
subplot(3, 2, 1);
plot(n, xn);
xlabel('n');
ylabel('x(n)');
title('(b) 三角波序列 x(n)');
grid on;

k = 0:1023;
wk = 2 * k / 1024;
subplot(3, 2, 2);
plot(wk, abs(Xk));
xlabel('\omega / \pi');
ylabel('|X(e^{j\omega})|');
title('(a) FT[x(n)]');
axis([0, 1, 0, 200]);
grid on;

k = 0:N/2-1;
subplot(3, 2, 3);
plot(k, abs(X16k));
xlabel('k');
ylabel('|X_{16}(k)|');
title('(c) 16 点频域采样');
axis([0, 8, 0, 200]);
grid on;

n1 = 0:N/2-1;
subplot(3, 2, 4);
plot(n1, x16n);
xlabel('n');
ylabel('x_{16}(n)');
title('(d) 16 点 IDFT[X_{16}(k)]');
axis([0, 32, 0, 20]);
grid on;

k = 0:N-1;
subplot(3, 2, 5);
plot(k, abs(X32k));
xlabel('k');
ylabel('|X_{32}(k)|');
title('(e) 32 点频域采样');
axis([0, 16, 0, 200]);
grid on;

n1 = 0:N-1;
subplot(3, 2, 6);
plot(n1, x32n);
xlabel('n');
ylabel('x_{32}(n)');
title('(f) 32 点 IDFT[X_{32}(k)]');
axis([0, 32, 0, 20]);
grid on;