-
大小: 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實現
評論
共有 條評論