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

📄 stbc_main.m

📁 自适应滤波原理_西蒙.赫金_Matlab_源代码 希望能够对学习自适应滤波技术的朋友有所帮助
💻 M
字号:
%A ST-block simulator based on paper IEEE J. on S. Comm.  Vol.17, No.3, March 1999
%
%Lsnr, Usnr : Lower and Upper SNR bound in dB
%nsymb : Number of symbols to transmit
%modtype : 'psk', 'qask' types of modulation one can use
%Mary : M-ary modulation
%stbc : G1  k=1, p=1, R=1       (One Tx antenna)
%       G2  k=2, p=2, R=1       (Two Tx antennas; Alamouti's code)
%       G3  k=4, p=8, R=1/2     (Four Tx antennas)
%       G4  k=4, p=8, R=1/2     (Four Tx antennas)
%       H3  k=3, p=4, R=3/4     (Four Tx antennas)
%       H4  k=3, p=4, R=3/4     (Four Tx antennas)
%Rate is defined as: R=k/p (Tx k symbols / p time slots)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%Define all User Parameters here
Lsnr=10;          %Lower SNR level
Usnr=22;         %Upper SRN level
nsymb=3e5;     %number of symbols to transmit
Mary = 8;        %Constellation size, Mary = 2^b where b is # of bits per symbol
modtype = 'psk'; %'psk' or 'qask'
stbc = 'G4';     %G1 G2 G3 G4 H3 H4
nRx = 1;         %Number of receive antennas to use
dobiterr = 'no'; %'yes' or 'no'; work with bit or symbol error respectively
%%%%%%%%
tic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Save file name
fname = sprintf('stbc_%s_%d%s_%dRx',stbc,Mary,modtype,nRx);
fid = fopen([fname '.txt'],'w');
fprintf(fid,'Starting receiver simulation : \n');
fclose(fid);

sigStr=['code' stbc];
err=ones(Usnr-Lsnr+1,1); %Define error vector
index=0;
for snr=Lsnr:Usnr,
    %Write to file to show routines' progress
    fid = fopen([fname '.txt'],'a');
    fprintf(fid,'Lower SNR: %d, Current SNR: %d, Upper SNR: %d, Elapsed Time: %6.0f \n',Lsnr,snr,Usnr,toc);
    fclose(fid);
   
    index=index+1;
    
    switch dobiterr
    case 'no'
        abscissa = 'SNR / (dB)';
        ordinate = 'Symbol Error Probability';
    case 'yes', 
        K=log2(Mary);
        snr=snr + 10*log10(K);
        abscissa = 'SNR / (dB)';
        ordinate = 'Bit Error Probability';
    end
    
    switch sigStr
    case 'codeG1'
        %Call routine for code G1 (no coding)
        [err]=codeG1(index,snr,nsymb,Mary,modtype,nRx,err);
        Rate = 1;
    case 'codeG2'
        %Call routine for code G2 2-by-nRx
        nsymb=nsymb - mod(nsymb,2);
        [err]=codeG2(index,snr,nsymb,Mary,modtype,nRx,err);
        Rate = 1;
    case 'codeG3'
        %Call routine for code G3 4-by-nRx
        nsymb=nsymb - mod(nsymb,4);
        [err]=codeG3(index,snr,nsymb,Mary,modtype,nRx,err);
        Rate = 1/2;
    case 'codeG4'
        %Call routine for code G4 4-by-nRx  
        nsymb=nsymb - mod(nsymb,4);
        [err]=codeG4(index,snr,nsymb,Mary,modtype,nRx,err);
        Rate = 1/2;
    case 'codeH3'
        %Call routine for code H3 3-by-nRx
        nsymb=nsymb - mod(nsymb,3);
        [err]=codeH3(index,snr,nsymb,Mary,modtype,nRx,err);
        Rate = 3/4;
    case 'codeH4'
        %Call routine for code H4 4-by-nRx
        nsymb=nsymb - mod(nsymb,3);
        [err]=codeH4(index,snr,nsymb,Mary,modtype,nRx,err);
        Rate = 3/4;
    end%switch
end%snr

save(fname)

fid = fopen([fname '.txt'],'a');
fprintf(fid,'FINISHED!!!   Total Elapsed Time: %6.0f\n',toc)    
fclose(fid);


%Plot the Results
figure(4)
speff = Rate*log2(Mary);
str = ['%d bps/Hz, %d receive antenna, Code ' stbc ' , %d ' modtype ' modulation'];
tle = [sprintf(str,speff,nRx,Mary)];
semilogy(Lsnr:Usnr,err/nsymb,'ko-');grid
xlabel(abscissa);ylabel(ordinate);
title(tle)
fprintf('Finished.\n')

⌨️ 快捷键说明

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