QPSK仿真系统MATLAB代码(超全!)

       实验流程就是按照上面的过程做的,还包含眼图、矢量图、星座图、误码率分析。所有代码全部手敲,注释是用英文写的,给大家分享一下,希望能够对大家有所帮助。

clc
clear all
close all

% Author: Mussy Max

%% Initializtion
symbol =1000; % numbers of symbols
bit = randi([0,1],1,2*symbol); % random bit
fc = 4e3; % carrier freq which determines how many carriers to represent
fs = 100e3; % sampling numbers of each pulse
sps = fs/(2*symbol); %samples of each pulse
T = 1; % time for each bit
figure(1);
subplot(2,1,1)
plot(bit);
title('raw bit');
time_delay = 0; % wether consodering the time delay of filter

%% GrayCode Pre-coding
Gray = [0,0;0,1;1,1;1,0];
bit_gray = [];
for i = 1:symbol
    dec = bit(2*i-1)*2+bit(2*i)+1;
    bit_gray(2*i-1) = Gray(dec,1);
    bit_gray(2*i) = Gray(dec,2);
end
bit_gray = 2*bit_gray-1;  % turn to NBRZ
subplot(2,1,2)
plot(bit_gray);
title('gray bit');

%% IQ separation
I_raw = [];Q_raw = [];
for i = 1:symbol
    I_raw(i) = bit_gray(2*i-1);
    Q_raw(i) = bit_gray(2*i);
end
figure(4); % draw constellation chart
subplot(1,2,1)
plot(I_raw,Q_raw,'*');xlabel('I');ylabel('Q')
axis([-2,2,-2,2]);
title('constellation chart of the transmitter')


figure(11); % draw constellation chart
subplot(1,2,1)
plot(I_raw,Q_raw);xlabel('I');ylabel('Q')
axis([-2,2,-2,2]);
title('vector chart of the transmitter')
%% design a pulse form filter
roff = 0.5;
cutoff_symbols = 6;
fir_rcos = rcosdesign(roff, cutoff_symbols, sps, "sqrt"); % defin
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值