www.gusucode.com > 实现不同收发天线数,不同调制方式下的误比特率测量matlab源码程序 > MIMO程序/runsim.m
function runsim(sim_options) %examine options fr_length=sim_options.FrmLen; Num=sim_options.NumberofPackets; channel_model=sim_options.ChannelModel; no_tx_antennas=sim_options.TxDiv; no_rx_antennas=sim_options.RxDiv; alpha=sim_options.corr_value; channel_est=sim_options.Channel_Est; modulation=sim_options.Modulation; if channel_est==0 type='stbc_per'; else type='stbc_est'; end if alpha~=0 & sim_options.Rx_corr==1 type='stbc_cor'; end %frame length = 130 symbols fr_length=130; %SNR upto 20 dBs EbNo=[0:2:20]; %N, M: number of transmit and receive antennas N=no_tx_antennas; M=no_rx_antennas; %choose type of stbc switch type case 'stbc_per' if N==1 & M==2 [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc12(channel_model,fr_length,Num,no_tx_antennas,no_rx_antennas,modulation) elseif N==2 & M==2 [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc22(channel_model,fr_length,Num,no_tx_antennas,no_rx_antennas,modulation) elseif N==2 & M==1 [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc21(channel_model,fr_length,Num,no_tx_antennas,no_rx_antennas,modulation) elseif N==3 & M==4 [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc34(channel_model,fr_length,Num,no_tx_antennas,no_rx_antennas,modulation) elseif N==3 & M==1 [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc31(channel_model,fr_length,Num,no_tx_antennas,no_rx_antennas,modulation) elseif N==4 & M==4 [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc44(channel_model,fr_length,Num,no_tx_antennas,no_rx_antennas,modulation) elseif N==4 & M==1 [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc41(channel_model,fr_length,Num,no_tx_antennas,no_rx_antennas,modulation) elseif N==1 & M==4 [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc14(channel_model,fr_length,Num,no_tx_antennas,no_rx_antennas,modulation) end case 'stbc_est' [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc22_est(channel_model,fr_length,Num,no_tx_antennas,no_rx_antennas,modulation) case 'stbc_cor' [FER FER_uncoded SER SER_uncoded BER BER_uncoded]=stbc22_cor(channel_model,fr_length,Num,alpha,no_tx_antennas,no_rx_antennas,modulation) otherwise 'No coding' end clc; str1=cd; str2=sim_options.FileName; str3=[str1 '\' str2]; if sim_options.Savefile==1 save(str3); end %plot routines. Choose FER/SER/BER as required figure; semilogy(EbNo,BER_uncoded,'r') hold on semilogy(EbNo,BER,'b') hold off xlabel('SNR [dB]') ylabel('BER') axis([min(EbNo) max(EbNo) 1e-6 1e0]) str1=num2str(N); str2=num2str(M); str=[str1 'x' str2]; legend('Uncoded',str); grid on str1='System:'; str2=num2str(N); str3=num2str(M); str4=[str1 str2 'x' str3]; title(str4); if channel_model=='AWGN ' model='AWGN'; else model='Rayleigh'; end str5=['Space-Time Block Coding-' model ' Channel']; set(gcf,'NumberTitle','off'); set(gcf,'Name',str5); grid on