Last active
June 6, 2017 07:20
-
-
Save MrWooJ/e95005a30ed80344608a to your computer and use it in GitHub Desktop.
WJMatlab-QPSK Coding Scehma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// QPSK Program | |
clc; | |
clear all; | |
close all; | |
xSignal = [ 1 0 0 1 1 0 1 0 1 1 ]; | |
bitPeriod = 0.000001; | |
Amplitude = 5; | |
bitRate = 1/bitPeriod; | |
frequency = bitRate; | |
% Data Signal Plot | |
FigHandle = figure('Position', [300, 100, 800, 800]); | |
subplot(5, 1, 1); | |
stem(xSignal, 'linewidth',3), grid on; | |
title('Information Before Transmiting '); | |
axis([ 0 11 0 1.5]); | |
nzrSignal = 2*xSignal-1; | |
spSignal = reshape(nzrSignal,2,length(xSignal)/2); | |
table = bitPeriod/99 : bitPeriod/99 : bitPeriod; | |
% QPSK Modulation Plot | |
y = []; | |
inphaseSignal = []; | |
quadratureSignal = []; | |
for i = 1 : length(xSignal)/2 | |
y1 = spSignal(1,i)*cos(2*pi*frequency*table); | |
y2 = spSignal(2,i)*sin(2*pi*frequency*table); | |
inphaseSignal = [inphaseSignal y1]; | |
quadratureSignal = [quadratureSignal y2]; | |
y = [y y1+y2]; | |
end | |
transmittingSignal = y; | |
table2 = bitPeriod/99 : bitPeriod/99 : (bitPeriod*length(xSignal))/2; | |
subplot(5, 1, 2); | |
plot(table2,inphaseSignal,'linewidth',3), grid on; | |
title('Inphase QPSK Modulation '); | |
xlabel('T(sec)'); | |
ylabel('A(volt0'); | |
subplot(5, 1, 3); | |
plot(table2,quadratureSignal,'linewidth',3), grid on; | |
title('Quadrature QPSK Modulation '); | |
xlabel('T(sec)'); | |
ylabel('A(volt0'); | |
subplot(5, 1, 4); | |
plot(table2,transmittingSignal,'r','linewidth',3), grid on; | |
title('QPSK Modulated Signal (Sum of Inphase and Quadrature Phase Signal)'); | |
xlabel('T(sec)'); | |
ylabel('A(volt0'); | |
% QPSK Demodulation Plot | |
receivedData = []; | |
receivedSignal = transmittingSignal; | |
for i = 1 : 1 : length(xSignal)/2 | |
inphaseDector = receivedSignal((i-1)*length(table)+1 : i*length(table)).*cos(2*pi*frequency*table); | |
inphaseDectorIntegrated=(trapz(table,inphaseDector))*(2/bitPeriod); | |
if inphaseDectorIntegrated > 0 | |
receivedInphaseData = 1; | |
else | |
receivedInphaseData = 0; | |
end | |
quadratureDector = receivedSignal((i-1)*length(table)+1:i*length(table)).*sin(2*pi*frequency*table); | |
quadratureDectorIntegrated = (trapz(table,quadratureDector))*(2/bitPeriod); | |
if quadratureDectorIntegrated > 0 | |
receivedQuadratureData = 1; | |
else | |
receivedQuadratureData = 0; | |
end | |
receivedData = [receivedData receivedInphaseData receivedQuadratureData]; | |
end | |
subplot(5, 1, 5); | |
stem(receivedData,'linewidth',3) | |
title('Information After Receiveing '); | |
axis([ 0 11 0 1.5]), grid on; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment