Sie sind auf Seite 1von 2

QAM – Modulation:

M = 32; x = [0:M-1];
y = qammod(x,M);
scale = modnorm(y,'peakpow',1);
y = scale*y; % Scale the constellation.
scatterplot(y); % Plot the scaled constellation.
hold on; % Make sure the annotations go in the same figure.
for jj=1:length(y)
text(real(y(jj)),imag(y(jj)),[' ' num2str(jj-1)]);
end
hold off;
-------------output---------------
Scatter plot

0 1 29 28
0.8

0.6
4 8 12 16 20 24
0.4

0.2
Quadrature

5 9 13 17 21 25

-0.2 6 10 14 18 22 26

-0.4
7 11 15 19 23 27
-0.6

-0.8
3 2 30 31
-0.5 0 0.5
In-Phase

QAM – Demodulation:

y = 4*(rand(1000,1)-1/2)+j*4*(rand(1000,1)-1/2);
z = qamdemod(y,4,pi/8);
% Find indices of points that mapped to the digits 0 and 3.
red = find(z==0); blue = find(z==3);
% Plot points corresponding to 0 and 3.
h = scatterplot(y(red,:),1,0,'r.'); hold on
scatterplot(y(blue,:),1,0,'b.',h);
legend('Points corresponding to 0','Points corresponding to 3');
hold off;
-----------output----------
Scatter plot

2
Points corresponding to 0
Points corresponding to 3
1.5

0.5
Q uadrature

-0.5

-1

-1.5

-2
-2 -1 0 1 2
In-Phase
FSK – Modulation:

M = 4; freqsep = 8; nsamp = 8; Fs = 32;


x = randint(1000,1,M); % Random signal
y = fskmod(x,M,freqsep,nsamp,Fs); % Modulate.
ly = length(y);
% Create an FFT plot.
freq = [-Fs/2 : Fs/ly : Fs/2 - Fs/ly];
Syy = 10*log10(fftshift(abs(fft(y))));
plot(freq,Syy)
--------------output------------------

40

20

-20

-40

-60

-80

-100

-120

-140
-20 -15 -10 -5 0 5 10 15 20

FSK –DeModulation:

M = 2; k = log2(M);
EbNo = 5;
Fs = 16; N = Fs;
nsamp = 17; freqsep = 8;
msg = randint(5000,1,M); % Random signal
txsig = fskmod(msg,M,freqsep,nsamp,Fs); % Modulate.
msg_rx = awgn(txsig,EbNo+10*log10(k)-10*log10(N),...
'measured',[],'dB'); % AWGN channel
msg_rrx = fskdemod(msg_rx,M,freqsep,nsamp,Fs); % Demodulate
[num,SER] = symerr(msg,msg_rrx); % Symbol error rate
BER = SER*(M/2)/(M-1) % Bit error rate
BER_theory = berawgn(EbNo,'fsk',M,'noncoherent') % Theoretical BER

------------------------output-----------------
BER = 0.1006
BER_theory = 0.1029

Das könnte Ihnen auch gefallen