?? recieve_onsat24.m
字號:
%**************************************************************************
%※ 星上數據接收端 ※%
%**************************************************************************
clc;
clear all;
close all;
load send_data2;
Rb=800000;%碼元速率819.2k
k=1; %一個碼元間隔包括1個載波周期/2
k2=8; %采樣率
fc=k*Rb; % 載波頻率,
fs=fc*k2; % 信號采樣率
x_size=k*k2;
%正交下變頻
%A/D模數變換
% [recievdataI,recievdataQ]=QPSK_demodu(upsenddata);
datalength=length(upsenddata);
recievdataI=upsenddataI;
recievdataQ=upsenddataQ;
%FFT分路
%*******解擴不解調************%
%產生本地載波恢復
carry_I(1:datalength)=cos(2*pi*fc*(1:datalength)/fs+pi/4);
carry_Q(1:datalength)=sin(2*pi*fc*(1:datalength)/fs+pi/4);
firstdemoduQ=recievdataQ.*carry_Q;
%產生15位擴頻短碼
shortPNcode=shortcode(datalength/k2);
% for var=1:channel
%產生42位擴頻長碼
longPNcode(1,:)=longcode1(datalength/k2,1);
%DSSoutdataI=mod(walshdata96I+longPNcode,2);
%DSSoutdataQ=mod(walshdata96Q+longPNcode,2);
%長短碼進行摸2加,生成本地擾碼
despreadcodeI(1,:)=mod(longPNcode(1,:)+shortPNcode(1,:),2);
despreadcodeQ(1,:)=mod(longPNcode(1,:)+shortPNcode(2,:),2);
%變為雙極性碼,0->1,1->-1
despreadcode1I(1,:)=-2*(despreadcodeI(1,:)-0.5);
despreadcode1Q(1,:)=-2*(despreadcodeQ(1,:)-0.5);
%對本地擾碼進行8倍采樣
for i=1:datalength/k2
despreadcode2I(1,1+(i-1)*k2:i*k2)=despreadcode1I(1,i);
despreadcode2Q(1,1+(i-1)*k2:i*k2)=despreadcode1Q(1,i);
end
%解擴
despreadout1I(1,:)=recievdataI.*despreadcode2I(1,:);
despreadout1Q(1,:)=recievdataQ.*despreadcode2Q(1,:);
firdemdespreQ=firstdemoduQ.*despreadcode2Q(1,:);
%%
%解調
N=9;
Wn=1/4;
B = fir1(N,Wn);
demoduoutI(1,:)=despreadout1I(1,:).*carry_I;
demoduoutQ(1,:)=despreadout1Q(1,:).*carry_Q;
demodudadaI(1,:)=filter2(B,demoduoutI(1,:));%filter2濾波器無延時,filter有延時
demodudataQ(1,:)=filter2(B,demoduoutQ(1,:));
demodudataI(1,k2/2+1:datalength)=demodudadaI(1,1:datalength-k2/2);
%[demodudataI(var,:),demodudataQ(var,:)]=QPSK_demodu2(despreadout1I(var,:),despreadout1Q(var,:));
% demodudata1I(var,:)=filter2(B,demodudataI(var,:));
% demodudata1Q(var,:)=filter2(B,demodudataQ(var,:));
%8:1下采樣,spreadtimes=24;
k3=spreadtimes*k2;
for i=1:datalength/k3
demodudata2I(1,i)=demodudataI(1,k3/2+1+k3*(i-1));
demodudata2Q(1,i)=demodudataQ(1,k3/2+1+k3*(i-1));
end
% end
%% *******************************%
demodudata3I=-(sign(demodudata2I)-1)/2;
demodudata3Q=-(sign(demodudata2Q)-1)/2;
%*************星上交換**********%
%CWTDM復接,去下行調制器
%% *******************************%
figure(2)
subplot(4,1,1)
plot(despreadout1Q(1,:))
%axis([0 k3*8 -1.5 1.5])
axis([0 k3 -2 2])
title('輸入解調信號')
grid on
subplot(4,1,2)
plot(carry_Q(1,:))
axis([0 k3 -1 1])
title('載波信號')
grid on
subplot(4,1,3)
plot(demoduoutQ(1,:))
axis([0 k3 -1 1])
title('解調輸出信號')
grid on
subplot(4,1,4)
plot(demodudataQ(1,:))
axis([0 k3 -1 1])
title('濾波輸出信號')
grid on
figure(3)
subplot(3,1,1)
stairs(despreadcode1Q(1,:))
%axis([0 k3*8 -1.5 1.5])
axis([1 k3/8+1 -1.2 1.2])
title('despreadcode1Q')
grid on
subplot(3,1,2)
plot(despreadcode2Q(1,:))
axis([0 k3 -2 2])
title('despreadcode2Q')
grid on
subplot(3,1,3)
plot(recievdataQ(1,:))
axis([0 k3 -1.2 1.2])
title('recievdataQ')
grid on
figure(4)
subplot(3,1,1)
plot(despreadcode2Q(1,:))
%axis([0 k3*8 -1.5 1.5])
axis([0 k3 -2 2])
title('despreadcode1Q')
grid on
subplot(3,1,2)
plot(firstdemoduQ(1,:))
axis([0 k3 -2 2])
title('firstdemoduQ')
grid on
subplot(3,1,3)
plot(firdemdespreQ)
axis([0 k3 -1.2 1.2])
title('firdemdespreQ')
grid on
% subplot(4,1,4)
% plot(carry_Q(1,:))
% axis([0 k3*2 -1 1])
% title('解調輸出信號')
% grid on
% %%
% figure(4)
% subplot(3,1,1)
% plot(demoduoutQ(1,:))
% %axis([0 k3*8 -1.5 1.5])
% axis([0 k3*2 -1.2 1.2])
% title('解調輸出信號demoduoutQ')
% grid on
% subplot(3,1,2)
% plot(demodudataQ(1,:))
% axis([0 k3*2 -1 1])
% title('濾波輸出信號demodudataQ')
% grid on
% subplot(3,1,3)
% plot(demodudata2Q(1,:))
% axis([1 k3/4 -1 1])
% title('下采樣輸出信號demodudata2Q')
% grid on
% %% *******************************%
% figure(3)
% subplot(2,1,1)
% % stairs(despreadout2I(1,:))
% % axis([1 k3/4 -1.2 1.2])
% % title('原始發送信號')
% % grid on
% % subplot(3,1,2)
% stairs(demodudata3I(1,:))
% %axis([0 k3*8 -1.5 1.5])
% axis([1 k3/4 -0.2 1.2])
% title('解擴輸出信號')
% grid on
% subplot(2,1,2)
% stairs(walshdataI(1,:))
% axis([1 k3/4 -0.2 1.2])
% title('原始發送信號')
% grid on
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -