?? gmsk.m
字號:
%***高斯濾波器***
Fb=1625*1000/6;
Tb=1/Fb;
Bb=0.3/Tb;
eta=sqrt(log(2))/(2*pi*Bb*Tb);
t=[-3*Tb:Tb/8:3*Tb]
h=(exp(-t.^2/(2*eta^2*Tb^2)))/(sqrt(2*pi)*eta*Tb)
subplot(311)
stem(t,h,'.')
%***矩形脈沖***
rect=[1 1 1 1 1 1 1 1]
t1=[-0.5*Tb:Tb/8:(3/8)*Tb]
subplot(312)
stem(t1,rect,'.')
%***信號經(jīng)高斯濾波器的輸出響應(yīng)
g=conv(rect,h)*Tb/8
subplot(313)
plot(g)
%*** 產(chǎn)生相位路徑表***
gt=g(9:48)
for n=1:5
for i=1:8
phasepath(n,i)=sum(gt((40-n*8+1):(40-n*8+i)))*pi/16
end
end
%***輸入信號***
a=[0 0 0 0 0;0 0 0 0 1;0 0 0 1 0;0 0 0 1 1;
0 0 1 0 0;0 0 1 0 1;0 0 1 1 0;0 0 1 1 1;
0 1 0 0 0;0 1 0 0 1;0 1 0 1 0;0 1 0 1 1;
0 1 1 0 0;0 1 1 0 1;0 1 1 1 0;0 1 1 1 1;
1 0 0 0 0;1 0 0 0 1;1 0 0 1 0;1 0 0 1 1;
1 0 1 0 0; 1 0 1 0 1;1 0 1 1 0;1 0 1 1 1;
1 1 0 0 0; 1 1 0 0 1;1 1 0 1 0;1 1 0 1 1;
1 1 1 0 0; 1 1 1 0 1;1 1 1 1 0;1 1 1 1 1;]
%***電平變換***
for i=1:32
for j=1:5
b(i,j)=2*a(i,j)-1;
end
end
%***碼元時(shí)刻相位累加函數(shù),假定初始相位為零***
PHASE(1)=sum(gt(1:32))*pi/16
PHASE(2)=sum(gt(1:24))*pi/16
PHASE(3)=sum(gt(1:16))*pi/16
PHASE(4)=sum(gt(1:8))*pi/16
PHASE(5)=sum(gt(1:0))*pi/16
%***相位增量表***
for i=1:32
for j=1:8
PHASE_TABLE_TEMP=0
for k=1:5
PHASE_TABLE_TEMP=PHASE_TABLE_TEMP+b(i,k)*(phasepath(k,j)+PHASE(k))
end
PHASE_TABLE(i,j)=PHASE_TABLE_TEMP;
COS_TABLE(i,j)=cos(PHASE_TABLE_TEMP);
SIN_TABLE(i,j)=sin(PHASE_TABLE_TEMP);
end
end
%***仿真全零調(diào)制的I Q 信號波形,和功率譜***
N=200
symbolsum=0
phasesum=0
m=5
INPUT=ones(1,N)%全零調(diào)制
% INPUT=2*mod(floor(randn(1,N)),2)-1%隨機(jī)序列調(diào)制
% for k=2:N-m
% sum=sum+INPUT(k-1)*pi/2%***采樣碼元時(shí)刻之前的碼元相位累加,用于判斷采樣時(shí)刻信號所處的象限***
% for i=1:32
% if INPUT(k:k+m-1)==b(i,1:m)
% TABLEROW=i;
% end
% end
% QOUTPUT(((k-1)*8+1):k*8)=cos(PHASE_TABLE(TABLEROW,1:8)+sum);
% IOUTPUT(((k-1)*8+1):k*8)=sin(PHASE_TABLE(TABLEROW,1:8)+sum);
% PHASEOUTPUT(((k-1)*8+1):k*8)=PHASE_TABLE(TABLEROW,1:8)+sum;
% end
for k=2:N-m
symbolsum=symbolsum+INPUT(k-1)
phasesum=phasesum+INPUT(k-1)*pi/2%***采樣碼元時(shí)刻之前的碼元相位累加,用于判斷采樣時(shí)刻信號所處的象限***
for i=1:32
if INPUT(k:k+m-1)==b(i,1:m)
TABLEROW=i;
end
end
if mod(symbolsum,4)==0
IOUTPUT(((k-1)*8+1):k*8)=cos(PHASE_TABLE(TABLEROW,1:8)+phasesum);
QOUTPUT(((k-1)*8+1):k*8)=sin(PHASE_TABLE(TABLEROW,1:8)+phasesum);
elseif mod(symbolsum,4)==1
IOUTPUT(((k-1)*8+1):k*8)=-sin(PHASE_TABLE(TABLEROW,1:8)+phasesum);
QOUTPUT(((k-1)*8+1):k*8)=cos(PHASE_TABLE(TABLEROW,1:8)+phasesum);
elseif mod(symbolsum,4)==2
IOUTPUT(((k-1)*8+1):k*8)=-cos(PHASE_TABLE(TABLEROW,1:8)+phasesum);
QOUTPUT(((k-1)*8+1):k*8)=-sin(PHASE_TABLE(TABLEROW,1:8)+phasesum);
elseif mod(symbolsum,4)==3
IOUTPUT(((k-1)*8+1):k*8)=sin(PHASE_TABLE(TABLEROW,1:8)+phasesum);
QOUTPUT(((k-1)*8+1):k*8)=-cos(PHASE_TABLE(TABLEROW,1:8)+phasesum);
end
PHASEOUTPUT(((k-1)*8+1):k*8)=PHASE_TABLE(TABLEROW,1:8)+phasesum;
end
figure(2)
subplot(311)
plot(QOUTPUT)
subplot(312)
plot(IOUTPUT)
subplot(313)
plot(PHASEOUTPUT)
% for i=1:32
% for j=1:8
% COS_TABLE_BINARY((i-1)*8+j,1:8)=decimal2bi(COS_TABLE(i,j),8)
% end
% end
% for i=1:32
% for j=1:8
% SIN_TABLE_BINARY((i-1)*8+j,1:8)=decimal2bi(SIN_TABLE(i,j),8)
% end
% end
fid = fopen('cos_table.txt','w');
for i=1:32
for j=1:8
fprintf(fid,'%i',decimal2bi(COS_TABLE(i,j),12));
fprintf(fid,'\n ');
end
end
fclose(fid);
fid = fopen('negative_cos_table.txt','w');
for i=1:32
for j=1:8
fprintf(fid,'%i',decimal2bi(-COS_TABLE(i,j),12));
fprintf(fid,'\n ');
end
end
fclose(fid);
fid = fopen('negative_sin_table.txt','w');
for i=1:32
for j=1:8
fprintf(fid,'%i',decimal2bi(-SIN_TABLE(i,j),12));
fprintf(fid,'\n ');
end
end
fclose(fid);
fid = fopen('sin_table.txt','w');
for i=1:32
for j=1:8
fprintf(fid,'%i',decimal2bi(SIN_TABLE(i,j),12));
fprintf(fid,'\n ');
end
end
fclose(fid);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -