• 大小: 4KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: Matlab
  • 标签: DPSK  matlab  

资源简介

可直接运行的matlab dpsk仿真代码,通过awgn信道

资源截图

代码片段和文件信息

clc
clear all
close all
% DPSK system
% assuming to have ideal channel H(z)=1
% AWGN
% initiate variances

symbol_num0=14;
symbol_num=symbol_num0+1;
b_d=zeros(1symbol_num0); % relative code
Rs=1200;                  % symbol rate
T=10;   % oversampling 7 points per symbol
s_t=zeros(1symbol_num*T);
f_C=1800; % the carrier frequence is 1800 Hz
fs=Rs*T;
ts=1/fs;
Eb=1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Tx  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% carrier generate 
t=0:1/fs:(symbol_num*T-1)/fs;
carrier_sig= sin(2*pi*f_C*t);

% code exchanger (absolute to differential)
b_org=unifrnd(-111symbol_num0)>0; % the absolute sequence b_n
%b_org=[1 0 0 1 0 0 1 1];
b_d(1)=1;                           % initiate the d_(n-1)‘s d(1)=1
for i=2:1:symbol_num                % get the d_(n-1)
    b_d(i)=xor(b_org(i-1)b_d(i-1));
end

% generate the square series with message
for n=1:symbol_num*T
    n_temp=ceil(n/T);
    s_t(n)=b_d(n_temp);
end

% another way to generate the dpsk 
s1=s_t.*carrier_sig;
s2=(ones(1symbol_num*T)-s_t).*(-carrier_sig);
%(-carrier means phase shift in pi)
s_t=s1+s2; % transmition signal is s_t



EbN0=20;
%%%%%%%%%%%%%%%%%%% creating the AWGN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mu=0;
N0=Eb/(10^(EbN0/10));
sigma=sqrt(N0*2);
gs_noise=normrnd(musigma[1 symbol_num*T]);
%another way: awgn(xsnr)
%gs_noise=zeros(1symbol_num*T);
%gs_noise=awgn(gs_noiseEbN0);
s_t1=s_t+gs_noise;
%s_t1=awgn(s_tEbN0‘measured‘);


%%%%%%%%%%%%%%%%%%%% Rx DPSK demodulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% pass a bandpass filter to get R_temp
lowpassband=f_C-Rs;
highpassband=f_C+Rs;
order=40;         % expecially the time of T
wn=[lowpassband highpassband]/(fs/2);
Filter_coefficient=fir1(orderwn);
R_temp=filter(Filter_coeffi

评论

共有 条评论