%% QDC Interpolation for every day
%
%%
function out_arr = qdc_interp(in_arr);
% --------------------------------------------------
%  The function interpolates QDC for every day from 
%  Actual Day array
%  in_arr - 1D array of Actual QDC
%  out_arr - 1D array of Every Day QDC 
% --------------------------------------------------
days = floor(length(in_arr)/1440);
% =======
% STEP 1
% construct 2D array of Actual QDC
j=0;
for i=0:days-1
  arr_day = in_arr(1+i*1440:1440+i*1440);
  if ~isnan(arr_day)
    j=j+1;  
    qDay(1:1440,j) = arr_day;
    da(j)=i+1;
  end % if ~isnan  
end % for i

% =======
% STEP 2
% interpolation and smoothing QDC for every day
 for i=1:1440
     interp_arr(i,:) = smooth(interp1(da,qDay(i,:),[1:days],'nearest','extrap'),60,'lowess');
     
 end;

% ======= 
% STEP 3
% Make 1D attay of the QDC
 for i=1:size(interp_arr,2)
    l_arr((i-1)*1440+1 : i*1440) = interp_arr(1:1440,i); 
 end   
out_arr = smooth(l_arr,120,'loess');