function [f_vals, x] = reconstCharacteristic( coeffs, dim, num_samples)
%
% [f_vals, x] = reconstCharacteristic( coeffs, dim, num_samples)
%

  defval( 'dim', numel(coeffs));
  defval( 'num_samples', 1000);

  % employ a normalized characteristic basis
  len_basis = 2.0 / dim;
  h = (1.0 / sqrt(len_basis));
 
  % x-axis sample values for signal
  x = [-1.0 : (2/(num_samples-1)) : 1.0];
  
  % memory for function values
  f_vals = zeros( size(x));
  
  x_min = -1.0;
  x_max = x_min + len_basis;
  
  for( i = 1 : dim)
    
    % index of values in interval where current characteristic function is
    % nonzero
    idx = (x >= x_min) & (x <= x_max);
    
    % set function values
    f_vals(idx) = coeffs(i) * h;
    
    % update interval for current characteristic function
    x_min = x_max;
    x_max = x_max + len_basis;
    
  end

end