How can I do QPSK in MATLAB
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