資源簡介
直接擴頻序列擴頻,2PSK調制,程序自己寫的,分享給大家,為了更好的模擬模擬信號,過低通用的卷積而沒有用IFFT,由于采樣點數過多,卷積耗時較長,請耐心等待:-)
代碼片段和文件信息
clear;
clc;
close?all;
%%?????基帶信號產生?擴頻碼產生
N=20;?????????????????????????%碼元個數?????????????????????????
xn1=round(rand(1N));?????????%單極性碼,碼元周期為10ms,頻率為100Hz?
xn1=1-2*xn1;??????????????????%雙極性碼???
Xn1=zeros(1200000);
Cn1=zeros(1200000);
for?i=1:20
????for?j=1:10000
????????Xn1(j+10000*(i-1))=xn1(i);??????%采樣,采樣周期為0.001ms,一個基帶信號碼元采樣10000次,頻率為1000000Hz
????end
end
cn1=m_creat([1?0?0?0?0?1?0?0?0?1][0?0?0?0?0?0?0?0?1]);??%511擴頻碼,雙極性碼,碼元周期為1ms頻率為1000Hz
cn11(1:200)=cn1(1:200);
for?i=1:200
????for?j=1:1000
????????Cn1(j+1000*(i-1))=cn11(i);
????end
end
figure?(1);
subplot(211);
plot(0:200/200000:200-200/200000Xn1);
axis([0?200?-1.5?1.5]);
xlabel(‘ms‘)
title(‘基帶信號‘);
f_Xn1=fft(Xn11000000)*1e-6;
subplot(212);
plot(0:1000000-1abs(f_Xn1));
axis([0?4000?0?0.1]);
xlabel(‘Hz‘);
title(‘基帶信號頻譜‘);
figure?(2);
subplot(211);
plot(0:200/200000:200-200/200000Cn1);
axis([0?200?-1.5?1.5]);
xlabel(‘ms‘);
title(‘m序列‘);
f_Cn1=fft(Cn11000000)*1e-6;
subplot(212);
plot(0:1000000-1abs(f_Cn1));
axis([0?4000?0?0.1]);
xlabel(‘Hz‘);
title(‘m序列頻譜‘);
%%???擴頻
Zn1=Xn1.*Cn1;
figure(3);
subplot(211);
plot(0:200/200000:200-200/200000Zn1);
axis([0?200?-1.5?1.5]);
xlabel(‘ms‘)
title(‘擴頻序列‘);
f_Zn1=fft(Zn11000000)*1e-6;
subplot(212);
plot(0:1000000-1abs(f_Zn1));
axis([0?4000?0?0.1]);
xlabel(‘Hz‘)
title(‘擴頻序列頻譜‘);
%%???過低通
Wp=2*pi*990/1000000;??%通帶邊界頻率
Ws=2*pi*1010/1000000;?%阻帶截止頻率
Wc=(Wp+Ws)/2/pi;????%通帶截止頻率
Bt=Ws-Wp;??????%過渡帶寬
N=round(8*pi/Bt);??%濾波器長度
LPF=fir1(N-1Wchanning(N));???%漢寧窗
figure(4);
plot(0:200000-1LPF);
title(‘漢寧窗‘)
Zn1_LPF=conv(LPFZn1);
Zn1_LPF1=Zn1_LPF(100000:300000-1);???%消除時移過低通之后的信號
figure(5);
subplot(211);
plot(0:200/200000:200-200/200000Zn1_LPF1);
xlim([0?200]);????%設置x軸范圍
xlabel(‘ms‘);
title(‘過低通之后的擴頻序列‘);
f_Zn1_LPF1=fft(Zn1_LPF11000000)*1e-6;
subplot(212);
plot(0:1000000-1abs(f_Zn1_LPF1));
axis([0?4000?0?0.1]);
title(‘過低通之后的擴頻序列頻譜‘);
%%??調制
Carrier=cos(2*pi*20000/1000000*(0:199999));???%載波頻率為20000Hz
Zn1_Mod=Zn1_LPF1.*Carrier;???%已調信號
%Zn1_Mod=Zn1.*Carrier;???%已調信號
figure(6);
subplot(211);
plot(0:200/200000:200-200/
- 上一篇:圖像對比度計算MATLAB代碼
- 下一篇:10用戶CDMA matlab實現
評論
共有 條評論