function [ n_car, n_fft, cp_1st, cp_oth, prb, Ts] = f_calc_params( del_f, B )
%   Function for calculation paramaters of 5G
%Inputs:  del_f [kHz] - subcarrier spacing
%         B[MHz]      - bandwidth
%Outputs: n_car       - number of subcarriers(data subcarriers)
%         n_fft       - size of FFT
%         cp_1st[symbols] - cyclix prefix length for begin half of subframe
%         cp_oth[symbols] - rest cyclix prefix
%
%

  max_car_size  = 3300; %carriers
  min_prb       = 24;
  max_prb       = 275; %physical resource block
  n_fft         = 0;
  cp_oth        = 0;
  cp_1st        = 0;
  tsubframe     = 1; %[ms]
  
  n_car_subr = floor((B*1e6)/(del_f*1e3));
  %Number of physical resource blocks
  prb = floor(n_car_subr/12);
  %number of carriers
  n_car = prb*12;
  
  if ((prb < max_prb) && (prb > min_prb))
    %Selecting number of FFt symbols (FFT size)
    if n_car < 512
      n_fft = 512;
    elseif n_car < 1024
      n_fft = 1024;
    elseif n_car < 2048
      n_fft = 2048;
    elseif n_car < 4096
      n_fft = 4096;
    else
      disp('NFFT_LIMIT')
    end
    %cahnge for stable FFT size
    n_fft = 4096;
    
    %Sampling frequency and period
    fs = n_fft * del_f*1e3;
    Ts = 1/fs;

    %Choose length of cyclic prefix in symbols
    if n_fft == 512
      cp_oth = 36;
    elseif n_fft == 1024
      cp_oth = 72;
    elseif n_fft == 2048
      cp_oth = 144;
    elseif n_fft == 4096
      cp_oth = 288;
    else
      disp('CP_LIMIT')
    end

    %Compute of first cyclix prefix(per Slot/2=0.5ms)
    if del_f == 15
      cp_1st = ((tsubframe/2)*1e-3)/(Ts)-6*(n_fft+cp_oth)-n_fft;
    elseif del_f == 30
      cp_1st = ((tsubframe/2)*1e-3)/(Ts)-13*(n_fft+cp_oth)-n_fft;
    elseif del_f == 60
      cp_1st = ((tsubframe/2)*1e-3)/(Ts)-27*(n_fft+cp_oth)-n_fft;
    elseif del_f == 120
      cp_1st = ((tsubframe/2)*1e-3)/(Ts)-55*(n_fft+cp_oth)-n_fft;
    elseif del_f == 240
      cp_1st = ((tsubframe/2)*1e-3)/(Ts)-111*(n_fft+cp_oth)-n_fft;
    end
  else
    error('SUBCARRIER LIMIT! Enter another configuration of Bandwidth and Subcarrier spacing (Number of PRB is %i - must be in range from %d to %d)', prb, min_prb, max_prb);
    %disp('PRB_LIMIT <=> SUBCAR_LIMIT')

   
    
  end



  
  
  
  