?? recieve_onsat1.m
字號:
%**************************************************************************
%※ 星上數據接收端 ※%
%**************************************************************************
clc;
clear all;
close all;
load send_data1;
Rb=800000;%碼元速率819.2k
k=1; %一個碼元間隔包括1個載波周期/2
k2=8; %采樣率
k3=spreadtimes*k2;
%正交下變頻
%A/D模數變換
[recievdataI,recievdataQ]=QPSK_demodu(upsenddata);
datalength=length(upsenddata);
%FFT分路
%*******解擴不解調************%
%產生42位擴頻長碼
longPNcode=longcode(datalength/k2);
%DSSoutdataI=mod(walshdata96I+longPNcode,2);
%DSSoutdataQ=mod(walshdata96Q+longPNcode,2);
%產生15位擴頻短碼
shortPNcode=shortcode(datalength/k2);
%長短碼進行摸2加,生成本地擾碼
despreadcodeI=mod(longPNcode+shortPNcode(1,:),2);
despreadcodeQ=mod(longPNcode+shortPNcode(2,:),2);
%變為雙極性碼,0->1,1->-1
despreadcode1I=-2*(despreadcodeI-0.5);
despreadcode1Q=-2*(despreadcodeQ-0.5);
%對本地擾碼進行8倍采樣
for i=1:datalength/k2
despreadcode2I(1,1+(i-1)*k2:i*k2)=despreadcode1I(i);%將碼元展寬x_size倍
despreadcode2Q(1,1+(i-1)*k2:i*k2)=despreadcode1Q(i);%將碼元展寬x_size倍
end
%解擴
N=14;
Wn=1/8;
B = fir1(N,Wn);
despreadout1I=recievdataI.*despreadcode2I;
despreadout1Q=recievdataQ.*despreadcode2Q;
%下采樣,spreadtimes=4;
for i=1:datalength/spreadtimes
despreadout4I(1,i)=despreadout1I(spreadtimes/2+1+spreadtimes*(i-1));%將碼元展寬x_size倍
despreadout4Q(1,i)=despreadout1Q(spreadtimes/2+1+spreadtimes*(i-1));%將碼元展寬x_size倍
end
despreadoutI=filter2(B,despreadout4I);
despreadoutQ=filter2(B,despreadout4Q);
%% *******判決********************%
for i=1:length(despreadout4I)/k2
despreadout2I(1,i)=sum(despreadoutI(1+k2*(i-1):k2*i));%積分判決
despreadout2Q(1,i)=sum(despreadoutQ(1+k2*(i-1):k2*i));
% despreadout2I(1,i)=despreadout4I(k2/2+1+k2*(i-1));%抽樣判決
% despreadout2Q(1,i)=despreadout4Q(k2/2+1+k2*(i-1));
end
despreadout3I=-(sign(despreadout2I)-1)/2;
despreadout3Q=-(sign(despreadout2Q)-1)/2;
%*************星上交換**********%
%CWTDM復接,去下行調制器
%% *******************************%
figure(1)
subplot(3,1,1)
plot(despreadcode2Q)
%axis([0 k3*8 -1.5 1.5])
axis([0 k3*6 -1 1])
grid on
title('擴頻碼')
subplot(3,1,2)
plot(recievdataQ)
axis([0 k3*6 -1 1])
title('擴頻輸入信號')
grid on
subplot(3,1,3)
plot(despreadout1Q)
axis([0 k3*6 -1 1])
title('擴頻輸出信號')
grid on
figure(2)
subplot(2,1,1)
plot(despreadout4Q)
axis([0 k2*6 -1 1])
title('下采樣輸出信號')
grid on
subplot(2,1,2)
axis([0 k2*6 -1 1])
title('濾波輸出信號')
grid on
%% *******************************%
figure(3)
subplot(2,1,1)
stairs(despreadout3Q)
%axis([0 k3*8 -1.5 1.5])
axis([1 7 -0.5 1.5])
grid on
title('擴頻碼')
subplot(2,1,2)
stairs(walshdataQ)
axis([1 7 -0.5 1.5])
title('擴頻輸入信號')
grid on
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -