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: polynomialMoment.m
    path of file: ./repos/VFIToolkit-matlab/DiscretizationMethods/discretizeVAR1_FarmerToda
    
    the code of the file until where you have to start completion: function T = polynomialMoment(X,mu,scalingFactor,nMoments)


    
function T = polynomialMoment(X,mu,scalingFactor,nMoments)

% Purpose:
%       Compute the moment defining function used in discreteApproximation
%
% Usage:
%       T = FT_polynomialMoment(X,mu,scalingFactor,nMoment)
%
% Inputs:
% X     - (1 x N) vector of grid points
% mu    - location parameter (conditional mean)
% scalingFactor    - scaling factor for numerical stability (typically largest grid point)
% nMoments   - number of polynomial moments

% Check that scaling factor is positive
if isnan(scalingFactor) || (scalingFactor <= 0)
    error('sF must be a positive number')
end