⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gmsk.m

📁 本程序是针对WCDMA
💻 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,'.')
%***信号经高斯滤波器的输出响应
g=conv(rect,h)*Tb/8
subplot(313)
plot(g)
%*** 产生相位路径表***
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
%***码元时刻相位累加函数,假定初始相位为零***
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
%***仿真全零调制的I Q 信号波形,和功率谱***
N=200
symbolsum=0
phasesum=0
m=5
INPUT=ones(1,N)%全零调制
% INPUT=2*mod(floor(randn(1,N)),2)-1%随机序列调制
% for k=2:N-m
%     sum=sum+INPUT(k-1)*pi/2%***采样码元时刻之前的码元相位累加,用于判断采样时刻信号所处的象限***
% 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%***采样码元时刻之前的码元相位累加,用于判断采样时刻信号所处的象限***
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); 


        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -