基于matlab的数字信号滤波调制与解调的程序
时间: 2023-06-24 16:09:29 浏览: 62
以下是基于 MATLAB 的数字信号滤波调制与解调的示例程序:
数字信号滤波:
```matlab
% 生成一个数字信号
fs = 1000; % 采样率为1000Hz
t = 0:1/fs:1-1/fs; % 时域范围为1秒
f1 = 10; % 信号频率为10Hz
f2 = 50; % 信号频率为50Hz
x = sin(2*pi*f1*t) + sin(2*pi*f2*t); % 构造信号
% 设计一个低通滤波器
fc = 30; % 截止频率为30Hz
[b, a] = butter(4, 2*fc/fs); % 4阶巴特沃斯滤波器
% 对信号进行滤波
y = filter(b, a, x);
% 绘制原始信号和滤波后的信号
subplot(2, 1, 1)
plot(t, x)
xlabel('Time (s)')
ylabel('Amplitude')
title('Original Signal')
subplot(2, 1, 2)
plot(t, y)
xlabel('Time (s)')
ylabel('Amplitude')
title('Filtered Signal')
```
数字信号调制:
```matlab
% 生成一个数字信号
fs = 1000; % 采样率为1000Hz
t = 0:1/fs:1-1/fs; % 时域范围为1秒
f1 = 10; % 信号频率为10Hz
x = sin(2*pi*f1*t); % 构造信号
% 生成一个载波信号
fc = 100; % 载波频率为100Hz
c = sin(2*pi*fc*t); % 构造信号
% 对数字信号进行调制
m = x .* c;
% 绘制数字信号、载波信号和调制后的信号
subplot(3, 1, 1)
plot(t, x)
xlabel('Time (s)')
ylabel('Amplitude')
title('Original Signal')
subplot(3, 1, 2)
plot(t, c)
xlabel('Time (s)')
ylabel('Amplitude')
title('Carrier Signal')
subplot(3, 1, 3)
plot(t, m)
xlabel('Time (s)')
ylabel('Amplitude')
title('Modulated Signal')
```
数字信号解调:
```matlab
% 对调制信号进行解调
dem = m .* c;
% 设计一个低通滤波器
fc = 30; % 截止频率为30Hz
[b, a] = butter(4, 2*fc/fs); % 4阶巴特沃斯滤波器
% 对解调信号进行滤波
y = filter(b, a, dem);
% 绘制调制信号、解调信号和滤波后的信号
subplot(3, 1, 1)
plot(t, m)
xlabel('Time (s)')
ylabel('Amplitude')
title('Modulated Signal')
subplot(3, 1, 2)
plot(t, dem)
xlabel('Time (s)')
ylabel('Amplitude')
title('Demodulated Signal')
subplot(3, 1, 3)
plot(t, y)
xlabel('Time (s)')
ylabel('Amplitude')
title('Filtered Signal')
```
以上是数字信号滤波调制与解调的 MATLAB 示例程序,可以根据需要进行修改和优化。