# How can I do QPSK in MATLAB [closed]

Could you please explain the step below, what is the benefit of it and how does it work. . I do qpsk demodulation, do I started doing the meshgrid,

%%%%%%%de-qpsk
sM = 2;
[x,y] = meshgrid((-sM+1):2:(sM-1),(-sM+1):2:(sM-1));
alphabet = x(:) + 1i*y(:);

for k=1:N
datadeqpsk(k) = alphabet((dataqpdk_be(k) alphabet)==min(dataqpdk_be(k)-alphabet)); % dataqpdk_be is the data
end

dataend=[];


Till now, all is ok, so what the benefit of below step? how does it work? could you please explain?

     for ij=1:N
end
R_D_data_out=[R_D_data_out dataend];


thank you very much

• hey, this is a bit too broadly asked. You certainly understand much of that code, but have specific questions regarding to specific steps in there (if you don't understand most of the code, you will have to go back and do a Matlab tutorial – introductions to Matlab aren't really the focus of this site). So, please ask a specific question! Show what you've researched so far, what you've understood and what you need help with. – Marcus Müller Aug 11 '18 at 11:13
• Thank you, I'm still new learning the OFDM, maybe my questions are easy for you. I modified the question, could you please check and help me. – Fatima_Ali Aug 11 '18 at 13:00
• Thanks for the edit! It's always best to narrow down questions, because it enables us to give you an answer that helps you at all. That's why I asked – not because it was simple for me, but because we simply couldn't see what your problem was with the overall thing. – Marcus Müller Aug 11 '18 at 13:08

Your code is performing the QPSK demodulation. it's assigning the odd value for real value and even values for Imaginary valued Or, the opposite, try to re-check. And Then make the QPSK demodulation.

About you question, how to do the qpsk demodulation, you can do it as below:

% suppose you have data for 48, 2-bit symbols
data = randi([0 1],96,1);
% Create a QPSK modulator System object with bits as inputs and Gray-coded signal constellation
qpsk_mod = comm.QPSKModulator('BitInput',true);
% Modulate and plot the data
modData = step(qpsk_mod , data);
scatterplot(modData)


Go to MATLAB and check the help of comm.QPSKModulator, then you can explore the demodulation easily.

you can also check this web page for deep understanding https://www.gaussianwaves.com/2010/10/qpsk-modulation-and-demodulation-2/

Good Luck

• OK, thank you very much .. I will check and try to understand it well. – Fatima_Ali Aug 12 '18 at 7:28