You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: calcpmf.m
    path of file: ./repos/mdtoolbox/mdtoolbox
    
    the code of the file until where you have to start completion: function [pmf, xi] = calcpmf(data, xi, bandwidth, box, weight)
%% calcpmf
% calculate 1D potential of mean force from the 1D-data by using kernel density estimator
%
%% Syntax
% [pmf, xi] = calcpmf(data)
% pmf = calcpmf(data, xi)
% pmf = calcpmf(data, xi, bandwidth, box, weight)
%
%% Description
%
% * data      - one-dimensional data
%               [nframe x 1 double array]
% * xi        - equally spaced grid
%               [n x 1 or 1 x n double]
% * bandwidth - bandwidth of the Gaussian kernel function
%               [1 x 1 double]
% * box       - PBC box size if data is periodic.
%               If not given or empty, data is considered to be non-periodic. 
%               [1 x 1 double]
% * weight    - weights of observables in data. 
%               By default, uniform weight is used. 
%               [nframe x 1 double]
% * pmf       - potential of mean force
%               [m x n double array]
%

    
function [pmf, xi] = calcpmf(data, xi, bandwidth, box, weight)
%% calcpmf
% calculate 1D potential of mean force from the 1D-data by using kernel density estimator
%
%% Syntax
% [pmf, xi] = calcpmf(data)
% pmf = calcpmf(data, xi)
% pmf = calcpmf(data, xi, bandwidth, box, weight)
%
%% Description
%
% * data      - one-dimensional data
%               [nframe x 1 double array]
% * xi        - equally spaced grid
%               [n x 1 or 1 x n double]
% * bandwidth - bandwidth of the Gaussian kernel function
%               [1 x 1 double]
% * box       - PBC box size if data is periodic.
%               If not given or empty, data is considered to be non-periodic. 
%               [1 x 1 double]
% * weight    - weights of observables in data. 
%               By default, uniform weight is used. 
%               [nframe x 1 double]
% * pmf       - potential of mean force
%               [m x n double array]
%
%% Example
%# xi = -180:2:180; % grids
%# pmf = calcpmf(phi, xi, 3.0, 360);
%# s   = getconstants(); % get Boltzmann constant in kcal/mol/K
%# T   = 300.0;          % set temperature
%# pmf = s.KB*T*pmf;     % convert unit from KBT to kcal/mol
%# plot(xi, pmf); xlable('Phi [degrees]'); ylable('PMF [kcal/mol]');
%
%% See also
% calcpmf2d
%

%% setup
if ~exist('xi', 'var')
  xi = [];
end