2
$\begingroup$

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

$\endgroup$
  • $\begingroup$ I can't find "DFT N-by_N" matrix in your code. What the result do you expect? $\endgroup$ – Mohammad nagdawi Aug 7 '18 at 4:55
  • $\begingroup$ what is the relation between the first and second code? $\endgroup$ – Mohammad nagdawi Aug 7 '18 at 5:03
  • $\begingroup$ 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. $\endgroup$ – Fatima_Ali Aug 7 '18 at 7:40
2
$\begingroup$

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),:);

$\endgroup$
  • $\begingroup$ Thank you so much for your suggestion, it's OK .. and I will post the whole correct code as reference below. $\endgroup$ – Fatima_Ali Aug 7 '18 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.