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

📄 ofdm.m

📁 ofdm仿真程序有关信道传输中的多径效应
💻 M
字号:
%% simulation of OFDM through multipath channel
%% the time resolution is ts=1/Fs=0.078us
%% GSM TU channel: six rays
%% power    dB----->value     delay(us)
%%          -3.0	0.1897	    0        
%%           0		0.3785      0.2     
%%          -2.0	0.2388    	0.5       
%%          -6.0	0.0951    	1.6        
%%          -8.0	0.0600   	2.3        
%%          -10.0	0.0379   	5.0        

clear
error=zeros(1,100);
frame_total=1;


N=2048; %% number of subcarriers
G=120;  %% length of guard interval
multipath=[sqrt(0.1897)  0  sqrt(0.3785) 0 0 sqrt(0.2388) 0 0 0  0 sqrt(0.0951) 0 0 0 0 sqrt(0.06) 0 0 0 0 0 0 sqrt(0.0379)]; %% power
multipath_channel=zeros(1,length(multipath));
EN=[10];
r=zeros(1,length(EN));

for snr=1:length(EN)

    en = 10^((EN(snr))/10);
    sigma = 1/sqrt(2*en);

    for frame_temp=1:frame_total
    
        multipath_channel=multipath.*(randn(1,length(multipath_channel))+j*randn(1,length(multipath_channel)))*sqrt(0.5); %% rayleigh fading

        fdata=2*round(rand(1,N))-1;  %% BPSK data
        tdata=ifft(fdata,N)*sqrt(N); %% OFDM modulation
        
        tdata_guard=[zeros(1,G) tdata];[tdata(N-G:N) tdata]; %% add guard interval,cyclic prefix
        tdata_chan=filter(multipath_channel,[1],tdata_guard);;%% passing through the multipath channel
       
        tdata_chan_dguard=tdata_chan(G+1:N+G); %% discard the guard interval
        fdata_rev_channel=fft(tdata_chan_dguard,N)/sqrt(N);  %% OFDM channel estimation demodulate
        fchan_est=fdata_rev_channel./fdata;   %% frequency channel fading facor
        
        
        h=[multipath_channel,zeros(1,N+G-length(multipath))];
        fchan_est1=fft(h,N);
        %fchan_est1=fchan_1(:)+conj([fchan_1(G+1:N),zeros(1,G)]');
        
        figure
        plot([1:2048],fchan_est,'r',[1:2048],fchan_est1,'b')
        
        le=length(tdata_chan);
        noise=sigma*(randn(1,le)+j*randn(1,le));
        tdata_chan1=tdata_chan+noise; %% add the AWGN 
                     
        tdata_chan_dguard1=tdata_chan1(G+1:N+G); %% discard the guard interval
        fdata_rev=fft(tdata_chan_dguard1,N)/sqrt(N);
        
        fdata_rev1=fdata_rev.*conj(fchan_est);%% channel compensation
        error(snr)=error(snr)+sum(sign(real(fdata_rev1))~=fdata);
    end
end

ber=error(1:length(EN))/(N*frame_total)
r= 10.^(EN/10);
pb=0.5*(1-sqrt(r./(1+r)))


figure
semilogy(EN,ber,'b-*',EN,pb,'r-^')

⌨️ 快捷键说明

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