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: surfit.m
    path of file: ./repos/fixed-wing-sim/ExperimentalCarrierSimulink/code
    
    the code of the file until where you have to start completion: function BAS=surfit(D,ORDVER,ORDHOR)
%	polynomial SURface FIT with separate orders
%   in vertical and horizontal directions

    
function BAS=surfit(D,ORDVER,ORDHOR)
%	polynomial SURface FIT with separate orders
%   in vertical and horizontal directions
%Input:		
%		D = matrix
%		ORDVER polynomial ORDer for VERtical fit, def. 1
%       ORDHOR polynomial ORDer for HORizontal fit, def. ORDVER
%Output:	
%       BAS = Fitted Surface
%--------------------------------
% Demo
%       [X,Y]=meshgrid(1:100,1:100);
%       D=(X.^3/100-X.*Y+3000-Y.^2/2)/1000;
%       F=surfit(D,2,3);
%       norm(D(:)-F(:),Inf)
% ----------------------------------
%See also: POLYFIC, POLYVAC
%    Vassili Pastushenko,	11.11.2004. [PFE]
%==============================================================
NAR=nargin;
if NAR<1, error('Data needed'),end