0% found this document useful (0 votes)
345 views2 pages

Qam Matlab Code

The document generates random binary data, converts it to symbols using 16-QAM modulation in both binary and gray coded formats, adds AWGN noise, and demodulates the noisy signal. It then calculates and displays the bit error rates for both binary and gray coded modulation. Additionally, it generates 16-QAM constellations and impulse responses of an RRC filter.

Uploaded by

PragnaShastry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
345 views2 pages

Qam Matlab Code

The document generates random binary data, converts it to symbols using 16-QAM modulation in both binary and gray coded formats, adds AWGN noise, and demodulates the noisy signal. It then calculates and displays the bit error rates for both binary and gray coded modulation. Additionally, it generates 16-QAM constellations and impulse responses of an RRC filter.

Uploaded by

PragnaShastry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

clear all;

clc

n=30000;
M=16;
k=log2(M);
nsps = 1;
rng default

din = randi([0 1],n,1);

figure(1)
stem(din(1:40),'filled');
title('Random Bits');
xlabel('Bit Index');
ylabel('Binary Value');

dinmat = reshape(din,length(din)/k,k);
dinsym = bi2de(dinmat);

figure(2)
stem(dinsym(1:10));
title('Random Symbols');
xlabel('Symbol Index');
ylabel('Integer Value');

dmod = qammod(dinsym,M,'bin');
dmodg = qammod(dinsym,M,'gray');

ebno = 10;
snr = ebno + 10*log10(k/nsps);

rs = awgn(dmod,snr,'measured');
rsg = awgn(dmodg,snr,'measured');

splotfig = scatterplot(rs,1,0,'g.');
hold on;
scatterplot(dmod,1,0,'k*',splotfig);

demod = qamdemod(rs,M,'bin');
demodg = qamdemod(rsg,M);

doutmat = de2bi(demod,k);
dout = doutmat(:);

doutmatg = de2bi(demodg,k);
doutg = doutmatg(:);

[numerr,ber] = biterr(din,dout);
fprintf('the binary bit error rate is %5.2e ,from %d error\n',ber,numerr);

[numerrg,berg] = biterr(din,doutg);
fprintf('the gray bit error rate is %5.2e ,from %d error\n',berg,numerrg);

m=16;
x=(0:15)';
y1 = qammod(x,m,'bin');
scatterplot(y1)
text(real(y1)+0.1, imag(y1), dec2bin(x))
title('16 qam binary distribution');
axis([-4 4 -4 4])

y2 = qammod(x,16,'gray');
scatterplot(y2)
text(real(y2)+0.1, imag(y2), dec2bin(x));
title('16 qam gray distribution');
axis([-4 4 -4 4])

rolloff = 0.25;
span = 10;
nsps = 4;

rcfilter = rcosdesign(rolloff,span,nsps);

fvtool(rcfilter,'Analysis','Impulse');

M = 16;
k = log2(M);
numbits = 3e5;

rng default;
datain = randi([0 1],numbits,1);

datainmat = reshape(datain,length(datain)/k,k);
datasym = bi2de(datainmat);

datamod = qammod(datasym,M);

txsignal = upfirdn(datamod,rcfilter,nsps,1);

eyediagram(txsignal(1:2000),nsps*2);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy