GENERATING MPSK BER VS SNR

버전 1.0.0.0 (1.8 KB) 작성자: raghav khandelwal
GENERATING MPSK BER VS SNR
다운로드 수: 302
업데이트 날짜: 2015/5/14

라이선스 보기

clc;
clear all;
close all;
k=input('enter the no of bits');
M = 2^k; %size
N = k*10^3; % number of symbols
% k = log2(M); % b/symbol

a = [0:M-1]*2*pi/M; % phase values

SNRdB = [3:1:13]; % SNR range

sdB = SNRdB + 10*log10(k);

% Mbinary to Gray code conversion

b = [0:M-1];

map =bitxor(b,floor(b/2));

[tt ind] = sort(map);

c = zeros(1,N);

for i = 1:length(SNRdB)


bits = rand(1,N*k,1)>0.5; % random 1's and 0's

% binary to decikal
bin2DecMatrix = ones(N,1)*(2.^((k-1):-1:0)) ;
shape= reshape(bits,k,N).';

% decimal to binary
G= (sum(shape.*bin2DecMatrix,2)).';

% Gray code mapping
dec = ind(G+1)-1; %
ph= dec*2*pi/M;

% modulation
d= exp(1i*ph);
s = d;

% AWGN

n = 1/sqrt(2)*(randn(1,N) + 1i*randn(1,N));

% reciever
r = s + 10^(-sdB(i)/20)*n;

% demodulation

e = angle(r);

% phase

e(e<0) = e(e<0) + 2*pi;

c = 2*pi/M*round(e/(2*pi/M)) ;

c(c==2*pi) = 0;
cd = round(c*M/(2*pi));

% Decimal to Gray conversion

f = map(cd+1);
cb = dec2bin(f,k) ;


cb = cb.';
cb = cb(1:end).';
cb = str2num(cb).' ;


% errors
Err(i) = size(find(bits- cb),2);


end
sBer=Err/(N*k);
tBer =(1/k)*erfc(sqrt(k*10.^(SNRdB/10))*sin(pi/8));
% plot
figure
semilogy(SNRdB,tBer,'rs-','LineWidth',2);
hold on
semilogy(SNRdB,sBer,'kx-','LineWidth',2);

legend('theory', 'simulation');
xlabel('SNR dB')
ylabel('Bit Error Rate')
title('BER VS SNR M-PSK')

인용 양식

raghav khandelwal (2024). GENERATING MPSK BER VS SNR (https://www.mathworks.com/matlabcentral/fileexchange/50849-generating-mpsk-ber-vs-snr), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2009b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 MPSK에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0