matlab编程SC-FDE系统仿真源码程序 - matlab通信信号 - 谷速源码
下载频道> 资源分类> matlab源码> 通信信号> matlab编程SC-FDE系统仿真源码程序

标题:matlab编程SC-FDE系统仿真源码程序
分享到:

所属分类: 通信信号 资源类型:程序源码 文件大小: 30.55 KB 上传时间: 2019-12-01 23:11:53 下载次数: 55 资源积分:1分 提 供 者: jiqiren matlab编程SC-FDE系统仿真源码程序
内容:
echo off; 
clear all; 
close all; 
clc; 
%单载波频域均衡处理 
fprintf( 'Single Carrier Frequency Domain Equalization Simulation\n\n\n') ; 
tic  %启动时钟 
%------------------------------------------------------------------- % 
%                   Parameters  Declaration                          % 
%------------------------------------------------------------------- % 
%Initialize the parameters初始化参数 
%FrameNum = input('number of frames transmitted is(default=5000) ='); 
FrameNum=10;%发送的数据帧数 
if isempty(FrameNum) 
    FrameNum = 5; 
end 
%FrameSize = input('size of each frame is(default=256) ='); 
FrameSize=256; %每帧数据的大小 
if isempty(FrameSize) 
    FrameSize = 256; 
end 
%Chan =input('channel IR is(default=[0.227 0.46 0.688 0.46 0.227]) ='); 
Chan=[0.227 0.46 0.688 0.46 0.227];%通道脉冲响应 
if isempty(Chan) 
    Chan = [0.227 0.46 0.688 0.46 0.227]; 
end 
CPLen = FrameSize/8;%循环前缀大小CPLen=256/8= 
 
% ------------------------------------------------------------------- % 
%             Generate Transmit Signal  & BPSK Modulation             % 
% ------------------------------------------------------------------- % 
% generate the random binary stream for transmitting 
% 产生随机的二进制流对于发射 
BitsTranstmp = randi(1,FrameNum*FrameSize); 
% BitsTranstmp(1:10)为0,1的数据流 
% modulate,generate the BPSK symbols 
Table        = [-1 1]; 
% After the step upon,Table = [-1.0000-0.0000i 1.000] 
BitsTrans    = Table(BitsTranstmp+1);%产生发送的二进制数据流 
 
% 增加循环前缀 
% ------------------------------------------------------------------- % 
%                               Add CP                                % 
% ------------------------------------------------------------------- % 
% the function RESHAPE is to rearrange the BitsTrans to add cp for 
% convenience,reshape 重新安排BitsTrans用于增加cp 
AddCPtmp   = reshape(BitsTrans,FrameSize,FrameNum);%原始数据部分 
AddCP      = zeros(FrameSize+CPLen,FrameNum);      %最终增加CP的数据 
AddPrefix  = FrameSize-CPLen+1:FrameSize;          %存放CP的位置 
 
% the matrix below is as the same function of add cp to each frame one 
% by one,增加每帧 
AddCP      = [AddCPtmp(AddPrefix,:);AddCPtmp];     %将原始数据的部分数据作为CP 
 
% ------------------------------------------------------------------- % 
%                         Go Through The Channel                      % 
% ------------------------------------------------------------------- % 
RecChantmp = filter(Chan,1,AddCP);                     %经过通道滤波处理 
 
%---------------------------------------------------------------------- 
%  function explain :y = filter(b,a,x) 
%  y = filter(b,a,X) filters the data in vector X with the filter desc- 
%  ribed by numerator coefficient vector b and denominator coefficient 
%  vector a,if x is a matrix,filter operates on the columns of X,so we 
%  could use filter here. 
%---------------------------------------------------------------------- 
BerSnrTable = zeros(10,7); 
for snr = 0:9 
    BerSnrTable(snr+1,1) = snr*5; 
     
    % convert Eb/N0 from unit db to normal numbers 
    BerSnrTable(snr+1,2) = 10^(BerSnrTable(snr+1,1)/10); 
     
    % standard deviation of AWGN noise,噪声的标准偏差 
    BerSnrTable(snr+1,3) = 1/sqrt(2*BerSnrTable(snr+1,2)); 
     
    % add noise,增加噪声 
    RecChan = awgn(RecChantmp,snr*5,'measured'); 
     
    % ------------------------------------------------------------------- % 
    %                            Remove The CP                            % 
    % ------------------------------------------------------------------- % 
    RemovCP = zeros(FrameSize,FrameNum); 
    % the rows of (CPLen+1:FrameSize+CPLen)of matrix RecChan is the 
    % numbers which we wanted 
    RemovCP = RecChan(CPLen+1:FrameSize+CPLen,:); 
     
    % ------------------------------------------------------------------- % 
    %                   Frequency Domain Equalization                     % 
    % ------------------------------------------------------------------- % 
    % reshaping the matrix RemovCP for frequency domain equalization 
    BitsFilt = reshape(RemovCP,1,FrameSize*FrameNum); 
    TimeBitsRec = zeros(1,FrameSize*FrameNum); 
     
    % fft of channel coeffients通道系数fft 
    FreqChan = fft(Chan,FrameSize); 
    for i = 1:FrameNum 
        FreRectmp = zeros(1,FrameSize); 
        for j = 1:FrameSize 
            FreRectmp(j) = BitsFilt(j+(i-1)*FrameSize); 
        end 
 
        % fft of received frames,接收帧 
        FreqRec = zeros(1,FrameSize); 
        FreqRec = fft(FreRectmp); 
         
        % equaliztion coefficients,均衡系数 
        EqCoe = zeros(1,FrameSize); 
        EqCoe = conj(FreqChan)./(BerSnrTable(snr+1,3)^2+abs(FreqChan).^2); 
         
        % equaliztion,均衡 
        EqualFram = zeros(1,FrameSize); 
        EqualFram = FreqRec.*EqCoe; 
         
        % received bits of time domain,using ifft时域接收位,使用ifft 
        TimeFram = ifft(EqualFram); 
         
        %gained the received bits after equalization获取均衡后的接收位 
        for j1 = 1:FrameSize 
            TimeBitsRec(j1+((i-1)*FrameSize)) = TimeFram(j1); 
        end 
    end 
     
    % 执行判决处理 
    % ------------------------------------------------------------------- % 
    %              Make Decision (Including Demodulate BPSK)              % 
    % ------------------------------------------------------------------- % 
    BitsRec = zeros(1,FrameSize*FrameNum); 
    for m = 1:FrameSize*FrameNum 
        Real =real(TimeBitsRec(m)); 
        if Real>0 
            BitsRec(1,m)=1; 
        else 
            BitsRec(1,m)=0; 
        end 
    end 
     
    % ------------------------------------------------------------------- % 
    %                Compute Bits&Frame Error Number&Rate                 % 
    % ------------------------------------------------------------------- % 
    % compute the frame error rate and number 
    RecFrame = reshape(BitsRec,FrameSize,FrameNum); 
    GenFrame = reshape(BitsTranstmp,FrameSize,FrameNum); 
    FrameErrNum = 0; 
    for n = 1:FrameNum 
        if GenFrame(:,n) == RecFrame(:,n) 
            FrameErrNum = FrameErrNum; 
        else 
            FrameErrNum = FrameErrNum+1; 
        end 
    end 
    BerSnrTable(snr+1,6) = FrameErrNum; 
    BerSnrTable(snr+1,7) = FrameErrNum/FrameNum; 
     
    % comput the bits error rate and number 
    [ErrNum,Ber] = symerr(BitsTranstmp,BitsRec) 
 
    BerSnrTable(snr+1,4) = ErrNum ; 
    BerSnrTable(snr+1,5) = Ber ; 
    % end of (for snr = 0:9) 
end 
 
figure(1); 
plot(BerSnrTable(:,1),BerSnrTable(:,4),'o-');grid on; 
title({'Simulation of Single Carrier with Frequency Domain Equalization';'Modulation Method:BPSK';'Channel Coefficients [0.227 0.46 0.688 0.46 0.227]';'';'bit error number of SC-FDE simulation'}) 
xlabel('SNR(db)');ylabel('BIT ERR NUMBER') 
 
figure(2) 
plot(BerSnrTable(:,1),BerSnrTable(:,5),'o-');grid on; 
title({'Simulation of Single Carrier with Frequency Domain Equalization';'Modulation Method:BPSK';'Channel Coefficients [0.227 0.46 0.688 0.46 0.227]';'';'bit error rate of SC-FDE simulation'}) 
xlabel('SNR(db)');ylabel('BIT ERR RATE') 
 
time_of_sim = toc 
echo on;

文件列表(点击上边下载按钮,如果是垃圾文件请在下面评价差评或者投诉):

main.m
毕业设计任务书.docx
程序.txt

关键词: matlab 编程 SC-FDE 系统 仿真 源码 程序

Top_arrow
回到顶部
联系方式| 版权声明| 招聘信息| 广告服务| 银行汇款| 法律顾问| 兼职技术| 付款方式| 关于我们|
网站客服网站客服 程序员兼职招聘 程序员兼职招聘
沪ICP备19040327号-3
公安备案号:沪公网安备 31011802003874号
库纳格流体控制系统(上海)有限公司 版权所有
Copyright © 1999-2014, GUSUCODE.COM, All Rights Reserved