# 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

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 !!

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

• I can't find "DFT N-by_N" matrix in your code. What the result do you expect? Aug 7 '18 at 4:55
• what is the relation between the first and second code? Aug 7 '18 at 5:03
• Hello Mohammed, in the first code we take the iFFT line by line .. in the second code I should take the iFFT N-by-N .. it's expected to get the same results. Aug 7 '18 at 7:40