function [ data_out] = f_insert_cp( data_in, N_fft, cp_1st, cp_oth, del_f )
%UNTITLED Summary of this function goes here
%   
  %Convert into matrix for better insert of CP
  data_resh = reshape(data_in, N_fft, length(data_in)/N_fft);
  data_resh = data_resh';
  
  %data_resh = vec2mat(data_in,N_fft);
  
  %number of rows
  row_num = length(data_resh(:,1))
  
  if del_f == 15
    n = 7;
  elseif del_f == 30
    n = 14;
  elseif del_f == 60
    n = 28;
  elseif del_f == 120
    n = 56;
  elseif del_f == 240
    n = 128;
  end
  
  %M_cp1 = zeros(1, cp_1st+N_fft);
  %M_cp  = zeros(1, cp_oth+N_fft);
  
  %Inserting of first CP
%   M_cp(1,:) = [data_resh(1,((end-cp_1st+1):end)),...
%               data_resh(1,:)];
  M_cp1 = [data_resh(1,((end-cp_1st+1):end)),...
           data_resh(1,:)];
  data_out = M_cp1;
  %data_out(1,1:N_fft+cp_1st) = M_cp(1,:);
  for i=1:1:row_num-1
    
    if mod(i,n) == 0
%       M_cp(i+1,:) = [data_resh(i+1,((end-cp_1st+1):end)),...
%                     data_resh(i+1,:)];
        M_cp1 = [data_resh(i+1,((end-cp_1st+1):end)),...
                 data_resh(i+1,:)];
      data_out = [data_out, M_cp1];
      %data_out(1,(((i-1)*N_fft)+cp_1st+1):((i*N_fft)+cp_1st)) = M_cp(i+1,:);
    else
%       M_cp(i+1,:) = [data_resh(i+1,((end-cp_oth+1):end)),...
%                     data_resh(i+1,:), ...
%                     zeros(1,(cp_1st-cp_oth))];
%       M_cp_nozero = [data_resh(i+1,((end-cp_oth+1):end)),...
%                     data_resh(i+1,:)];
      M_cp = [data_resh(i+1,((end-cp_oth+1):end)),...
              data_resh(i+1,:)];
      data_out = [data_out, M_cp];
      %data_out(1,(i-1)*N_fft+cp_oth+1:i*N_fft+cp_oth) = M_cp(i+1,1:end-(cp_1st-cp_oth));
    end

  end

  %data_matrix = M_cp;
end

