利用matlab实现利用半带滤波器实现完整的2倍内插过程 1) 在时间t=0:1秒内生成一个离散正弦信号,参数为:fs=10kHz,f=1kHz,幅值为1, 分别画出采用1000点和1024点FFT的信号频谱图(要求横坐标用绝对频率表示, 纵坐标以dB为单位),并简单分析频谱图差异的原因; 2) 画出上述信号进行2倍内插后的时域图和频谱图,指出内插后产生镜像频率的位 置和个数;(时域图只画t=0.59:0.60,FFT采用1000点,频谱图要求横坐标用 绝对频率表示,纵坐标以dB为单位) 3) 利用题1中设计的32阶半带滤波器作为抗镜像滤波器,画出2)中内插后的信号经 过半带滤波器后的时域图和频谱图,并分析镜像频率的抑制情况;(时域图只 画t=0.59:0.60,FFT采用1000点,频谱图要求横坐标用绝对频率表示,纵坐标 以dB为单位)
时间: 2024-02-21 13:57:49 浏览: 133
好的,以下是matlab代码实现:
1)生成离散正弦信号并画出频谱图:
```
% 生成离散正弦信号
fs = 10000; % 采样频率
f = 1000; % 正弦信号频率
t = 0:1/fs:1-1/fs; % 时间向量
x = sin(2*pi*f*t); % 离散正弦信号
N1 = 1000; % FFT采样点数
N2 = 1024;
X1 = fft(x,N1); % 1000点FFT
X2 = fft(x,N2); % 1024点FFT
f1 = (0:N1-1)*fs/N1; % 频率向量
f2 = (0:N2-1)*fs/N2;
figure;
subplot(2,1,1);
plot(f1,20*log10(abs(X1))); % 1000点FFT频谱图
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
title('1000-point FFT of the Discrete Sine Signal');
subplot(2,1,2);
plot(f2,20*log10(abs(X2))); % 1024点FFT频谱图
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
title('1024-point FFT of the Discrete Sine Signal');
```
分析:由于1024点FFT采样点数更多,所以频率分辨率更高,能够更清晰地显示信号频率和谐波的位置和幅值,而1000点FFT的频率分辨率较低,无法清晰地显示信号频率和谐波的位置和幅值。
2)进行2倍内插并画出时域图和频谱图:
```
% 进行2倍内插
y = interp(x,2); % 2倍内插
Y = fft(y,N1); % 1000点FFT
t_zoom = 0.59:1/fs/2:0.60; % 缩放后的时间向量
y_zoom = y(t_zoom*fs*2+1); % 缩放后的信号
Y_zoom = fft(y_zoom,N1); % 缩放后的信号FFT
f_zoom = (0:N1-1)*fs/N1/2; % 缩放后的频率向量
figure;
subplot(2,1,1);
plot(t_zoom,y_zoom); % 信号的2倍内插时域图
xlabel('Time (s)');
ylabel('Amplitude');
title('2x Interpolation of the Discrete Sine Signal');
subplot(2,1,2);
plot(f_zoom,20*log10(abs(Y_zoom))); % 信号的2倍内插频谱图
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
title('FFT of the 2x Interpolation of the Discrete Sine Signal');
```
分析:内插后产生了一个镜像频率,位于采样频率的一半处(5000 Hz),且幅值与原信号的幅值相等。
3)利用半带滤波器进行抗镜像滤波并画出时域图和频谱图:
```
% 设计32阶半带滤波器
h = fir1(32,1/4,'high'); % 半带滤波器
z = conv(y,h); % 内插后的信号经过半带滤波器
Z = fft(z,N1); % 1000点FFT
z_zoom = z(t_zoom*fs*2+1); % 缩放后的信号经过半带滤波器
Z_zoom = fft(z_zoom,N1); % 缩放后的信号经过半带滤波器FFT
figure;
subplot(2,1,1);
plot(t_zoom,z_zoom); % 经过半带滤波器的信号时域图
xlabel('Time (s)');
ylabel('Amplitude');
title('2x Interpolation of the Discrete Sine Signal after Filtering');
subplot(2,1,2);
plot(f_zoom,20*log10(abs(Z_zoom))); % 经过半带滤波器的信号频谱图
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
title('FFT of the 2x Interpolation of the Discrete Sine Signal after Filtering');
```
分析:镜像频率被成功抑制,且滤波器的抗镜像效果比较好,信号频谱图的镜像峰幅值明显降低。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)