-
大小: 5KB文件类型: .m金币: 1下载: 0 次发布日期: 2021-05-16
- 语言: Matlab
- 标签: QPSK;MATLAB
资源简介
程序使用MATLAB语言设计,主要实现基于QPSK方式的调制解调,设计时,在调制端加入了成型滤波器,同时在解调端加入了匹配滤波器。
代码片段和文件信息
clear
%% 参数
frame_length=3000;
insert_multiple=14;
fs=210e6;
fc=70e6;
%% qpsk transmit
%基带信号
rand_data=rand(1frame_length);
for i=1:frame_length
if rand_data(i)>=0.5
rand_data(i)=1;
else
rand_data(i)=0;
end
end
%串并变换 ,极性转换
I=zeros(1frame_length/2);
Q=zeros(1frame_length/2);
count=1;
while count~=frame_length/2+1
if(rand_data(count*2-1)==0&&rand_data(count*2)==0)
I(count)=1;
Q(count)=1;
count=count+1;
elseif(rand_data(count*2-1)==0&&rand_data(count*2)==1)
I(count)=-1;
Q(count)=1;
count=count+1;
elseif(rand_data(count*2-1)==1&&rand_data(count*2)==0)
I(count)=1;
Q(count)=-1;
count=count+1;
elseif(rand_data(count*2-1)==1&&rand_data(count*2)==1)
I(count)=-1;
Q(count)=-1;
count=count+1;
end
end
%上变频
Izero=zeros(1insert_multiple*frame_length/2);
Qzero=zeros(1insert_multiple*frame_length/2);
Izero(1:insert_multiple:end)=I;
Qzero(1:insert_multiple:end)=Q;
psf=rcosfir(0.3510insert_multiplefs‘sqrt‘);
Ipulse=conv(Izeropsf);
Qpulse=conv(Qzeropsf);
% [yftf]=rcosine(1insert_multiple‘sqrt‘0.15);
% Ipulse=filter(yftfIzero);
% Qpulse=filter(yftfQzero);
%modulation
for i=1:length(Ipulse) %采样点数目改变 (因为卷积的缘故)
t(i)=(i-1)/(fs); %这里因为假设载频与码速率大小相等,所以用载频fc乘以过采样率=采样率。
Imod(i)=Ipulse(i)*sqrt(2)*cos(2*pi*fc*t(i));
Qmod(i)=Qpulse(i)*(-sqrt(2)*sin(2*pi*fc*t(i)));
end
sum=Imod+Qmod;
%% QPSK receiver
%demodulation
for i=1:length(Ipulse)
Idem(i)=sum(i)*sqrt(2)*cos(2*pi*fc*t(i));
Qdem(i)=sum(i)*(-sqrt(2)*sin(2*pi*fc*t(i)));
end
%matched filter
% mtf=rcosfir(rollNTinsert_multiplefs‘sqrt‘);
Imat=conv(Idempsf);
Qmat=conv(Qdempsf);
%data selection
for i=1:insert_multiple*frame_length/2
Isel(i)=Imat(i+length(psf)-1);
Qsel(i)=Qmat(i+length(psf)-1);
end
%sampler %提取码元
for i=1:frame_length/2
Isam(i)=Isel((i-1)*insert_multiple+1);
Qsam(i)=Qsel((i-1)*insert_multiple+1);
end
%decision threshold
threshold=0.2;
for i=1:frame_length/2
if Isam(i)>=threshold
Ifinal(i)=1;
else
Ifinal(i)=-1;
end
if Qsam(i)>=threshold
Qfinal(i)=1;
else
Qfinal(i)=-1;
end
end
%% 画图
figure(1);
plot(20*log(abs(fft(rand_data))));
% axis([0 frame_length -40 100]);
grid on;
title(‘spectrum of input binary data‘);
figure(2)
subplot(221);
plot(20*log(abs(fft(I))));
% axis([0 amount -40 140]);
grid on;
title(‘spectrum of I-channel data‘);
subplot(222);
p
- 上一篇:用SOM做分类器
- 下一篇:Camshift目标跟踪matlab实现
评论
共有 条评论