issue in DFT of OFDM by blocks and N-by-N I'm trying to study and understand the OFDM, and during coding the OFDM in MATLAB, I faced this issue: 

suppose we have the Numsymbol = 256, and dataqpsk our used data, The issue which I face that when I perform iFFT block by block, that seems to be ok, but when trying to make it N-by-N .. that gives a problem. 

here is the steps. now I will make the iFFT by blocks : 

clear all; clc; 

N_carrier = 256;  % number of carrier
N_symbol = 256;  %number of symbols
N_FFT = 256;  %length of FFT
N = N_carrier;
L_cp = N/4;   % the CP 

dataqpsk = rand(N_carrier,N_symbol);  %Example for modulated data
size(dataqpsk); 
for isij=1: N_symbol
    % input modulated data
    dataqpsk1=dataqpsk(:,isij);     
    size(dataqpsk1)
    D_map = dataqpsk1;

    %% doing such mapping 
    D_IFFT_fore=zeros(N_FFT,1);
    D_IFFT_fore(1:(N/2)) = [D_map(((N/2)+1):N)];
    D_IFFT_fore((N_FFT-((N/2)-1)):N_FFT) = [D_map(1:(N/2))];
    D_IFFT_aft=N_FFT.*ifft(D_IFFT_fore,N_FFT);%×÷ifft

    %add GI and interpolation.
    D_cp=[D_IFFT_aft(N_FFT-L_cp+1:N_FFT);D_IFFT_aft];
end 


But now when I try to make it as DFT N-by_N I don't get, as below: 

clear all; clc; 

N_carrier = 256;  % number of carrier
N_symbol = 256;  %number of symbols
N_FFT = 256;
N = N_carrier;
L_cp = N/4;  %CP

dataqpsk = rand(N_carrier,N_symbol);
size(dataqpsk); 
D_map = dataqpsk; 
D_IFFT_fore=zeros(N_FFT,N_FFT);
D_IFFT_fore(1:(N/2)) = [D_map(((N/2)+1):N)];
D_IFFT_fore((N_FFT-((N/2)-1)):N_FFT) = [D_map(1:(N/2))];
D_IFFT_aft = N_FFT.*ifft(D_IFFT_fore,N_FFT); % ifft
D_cp(1:L_cp,1:N_FFT)=D_IFFT_aft(N_FFT-L_cp+1:N_FFT,1:N_FFT);


The problem is when trying get the results of DFT N-by_N, I get from the step of D_IFFT_fore(1:(N/2)) = [D_map(((N/2)+1):N)];  a matrix of Zeros !! 

please, any help? 

thank you 



Thank you Dear msm, and here is the complete code: 

clear all; clc; 

N_carrier = 256;  % number of carrier
N_symbol = 256;  %number of symbols
N_FFT = 256;
N = N_carrier;
L_cp = N/4;  %CP

dataqpsk = rand(N_carrier,N_symbol);
size(dataqpsk); 
D_map = dataqpsk; 
D_IFFT_fore=zeros(N_FFT,N_FFT);
D_IFFT_fore(1:(N/2),:) = [D_map(((N/2)+1):N,:)];
D_IFFT_fore((N_FFT-((N/2)-1)):N_FFT,:) = [D_map(1:(N/2),:)];
D_IFFT_aft = N_FFT.*ifft(D_IFFT_fore,N_FFT); % ifft
D_cp(1:L_cp,1:N_FFT)=D_IFFT_aft(N_FFT-L_cp+1:N_FFT,1:N_FFT);


thanks again
Try using something like the following. You want to map the rows this way for all columns, hence the colon to denote all columns. Double-check that you get what you want from these. I didn't run it to verify it gives exactly what you want, but it should fully populate all columns, I believe.

D_IFFT_fore(1:(N/2),:) = D_map(((N/2)+1):N,:);
D_IFFT_fore((N_FFT-((N/2)-1)):N_FFT,:) = D_map(1:(N/2),:);