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: fitPolynomialTransform2d.m
    path of file: ./repos/matGeom/matGeom/geom2d
    
    the code of the file until where you have to start completion: function coeffs = fitPolynomialTransform2d(pts, ptsRef, degree)

    
function coeffs = fitPolynomialTransform2d(pts, ptsRef, degree)
%FITPOLYNOMIALTRANSFORM2D Coefficients of polynomial transform between two point sets.
%
%   COEFFS = fitPolynomialTransform2d(PTS, PTSREF, DEGREE)
%
%   Example
%  
%   See also 
%     polynomialTransform2d, fitAffineTransform2d

% ------
% Author: David Legland
% E-mail: david.legland@inrae.fr
% Created: 2013-11-05, using Matlab 7.9.0.529 (R2009b)
% Copyright 2013-2023 INRA - Cepia Software Platform

%% Extract data

% ensure degree is valid
if nargin < 3
    degree = 3;
end