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

资源简介

可以用的MATLAB 仿真程序,包括调制。信道部分,解调部分、

资源截图

代码片段和文件信息

clear; close all;

% Simulate continuous time
f_s = 2000000;    % 400 kHz (sampling rate)
T=0.1;           % 0.1 second
samples=f_s*T;   % total number of samples simulated
t=(0:(samples-1))/f_s; %time axis

% Generate bits
f_b=20000;       % bit_rate = 20 kbps
bits=f_b*T;      % number of bits simulated
rand(‘seed‘0);  % 
b=round(rand(1bits)); % random source bits


% Generate Symbols: QPSK symbols
bits_per_symbol=2;
f_symbol = f_b/bits_per_symbol;    % symbol rate = 20 ksym/s
symbols= bits/bits_per_symbol;     % number of BPSK symbols
samples_per_symbol=f_s/f_symbol;   % number of samples per BPSK symbol (20)


b_mat=reshape(bbits_per_symbolsymbols);
b_1=b_mat(1:);
b_2=b_mat(2:);
 
j=sqrt(-1);
a  =  1/sqrt(2);       % amplitude     
xk=a*((1-2*b_1)+j*(1-2*b_2)); % QPSK symbols
% figure;
% subplot(211)
% stem(0:1/f_symbol:(1/f_symbol)*49real(xk(1:50)));
% title(‘the plot of real[xk]‘);
% xlabel(‘time(s)‘);
% ylabel(‘Amplitude‘);
% subplot(212)
% stem(0:1/f_symbol:1/f_symbol*49imag(xk(1:50)));
% title(‘the plot of imag[xk]‘);
% xlabel(‘time(s)‘);
% ylabel(‘Amplitude‘);





% Upsampling to simulate impulses in continuous time
x_up = upsample(xk samples_per_symbol samples_per_symbol/2);

roll_off=0.5;            % filter‘s roll-off factor
f_cut_off = f_symbol/2;  % filter‘s cut-off frequency
filter_order=10;        % filter‘s order/factor
    
% Tx/Rx filter
B_rrcos=sqrt(samples_per_symbol)*firrcos(filter_order*samples_per_symbolf_cut_offroll_offf_s‘rolloff‘‘sqrt‘);

% Tx filter
xt=filter2(B_rrcosx_up);
% x(t) => after up_sampling and transmit filter

% Channel
c    = [10.5];                             % channel profile
c_up = upsample(c samples_per_symbol); % upsampling the channel

% convolution of x(t) and c(t)
xc = filter(c_up 1 xt);

% Rx filter
xhat=filter2(B_rrcosxc);

% Eye Diagram
repetition= 200;     % number of repetitions for the drawing of the eye diagram
EYE = zeros(2*samples_per_symbol repetition); % Two periods draw 200(=repetition) times
EYE(:) = xhat(samples_per_symbol*filter_order+1:(2*samples_per_symbol)*repetition+samples_per_symbol*filter_order)‘;  

%subplot(211);
%plot(1:2*samples_per_symbolreal(EYE)); grid;
%title([‘Real Eye Diagram (Received QPSK S

评论

共有 条评论