用MATLAB2020b编程实现2DPSK信号的调制解调(相干检测+码反变换)
时间: 2024-05-04 14:17:51 浏览: 120
基于MATLAB的2DPSK信号仿真.pdf
2DPSK调制:
```matlab
clear all;
close all;
% 信号参数
fc = 10e3; % 载波频率
fs = 100e3; % 采样频率
T = 1/fs; % 采样时间间隔
Ts = 1/fc; % 符号时间间隔
N = fs/fc; % 每个符号的采样数
% 信息序列
data = [1 0 1 1 0 1 0 0 1 1 0 0 0 1 0 1];
% 2DPSK调制
phi = 0;
for i = 1:length(data)
if data(i) == 1
phi = phi + pi/2;
else
phi = phi - pi/2;
end
for j = 1:N
x(j + (i-1)*N) = cos(2*pi*fc*(j-1)*T + phi);
end
end
% 画图
t = 0:T:(length(data)*N-1)*T;
figure(1);
plot(t, x);
xlabel('时间/s');
ylabel('幅度');
title('2DPSK调制信号');
```
2DPSK解调:
```matlab
clear all;
close all;
% 信号参数
fc = 10e3; % 载波频率
fs = 100e3; % 采样频率
T = 1/fs; % 采样时间间隔
Ts = 1/fc; % 符号时间间隔
N = fs/fc; % 每个符号的采样数
% 信息序列
data = [1 0 1 1 0 1 0 0 1 1 0 0 0 1 0 1];
% 2DPSK调制
phi = 0;
for i = 1:length(data)
if data(i) == 1
phi = phi + pi/2;
else
phi = phi - pi/2;
end
for j = 1:N
x(j + (i-1)*N) = cos(2*pi*fc*(j-1)*T + phi);
end
end
% 2DPSK解调
data_hat = zeros(1, length(data));
phi_hat = 0;
for i = 1:length(data)
for j = 1:N
y(j + (i-1)*N) = x(j + (i-1)*N)*cos(2*pi*fc*(j-1)*T + phi_hat) - sin(2*pi*fc*(j-1)*T + phi_hat)*imag(hilbert(x(j + (i-1)*N)));
end
if y(1 + (i-1)*N)*y(N + (i-1)*N) > 0
data_hat(i) = 1;
else
data_hat(i) = 0;
end
if data_hat(i) == 1
phi_hat = phi_hat + pi/2;
else
phi_hat = phi_hat - pi/2;
end
end
% 误码率
num_error = sum(data ~= data_hat);
ber = num_error/length(data);
disp(['误码率为:', num2str(ber)]);
% 画图
t = 0:T:(length(data)*N-1)*T;
figure(1);
subplot(2,1,1);
plot(t, x);
xlabel('时间/s');
ylabel('幅度');
title('2DPSK调制信号');
subplot(2,1,2);
plot(t, y);
xlabel('时间/s');
ylabel('幅度');
title('2DPSK解调信号');
```
阅读全文