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: lineFit.m
    path of file: ./repos/matGeom/matGeom/deprecated/geom2d
    
    the code of the file until where you have to start completion: function line = lineFit(varargin)
%LINEFIT Fit a straight line to a set of points.
%
%   Note: deprecated. Replaced by 'fitLine'.
%
%   L = lineFit(X, Y)
%   Computes parametric line minimizing square error of all points (X,Y).
%   Result is a 4*1 array, containing coordinates of a point of the line,
%   and the direction vector of the line, that is  L=[x0 y0 dx dy];
%
%   L = lineFit(PTS) 
%   Gives coordinats of points in a single array.
%
%   L = lineFit(PT0, PTS);
%   L = lineFit(PT0, X, Y);
%   with PT0 = [x0 y0], imposes the line to contain point PT0.
%
%   Requires:
%   Optimiaztion toolbox
%
%   See also 
%   lines2d, polyfit, polyfit2, lsqlin
%

% ------
% Author: David Legland 
% E-mail: david.legland@inrae.fr
% Created: 2004-04-30
% Copyright 2004-2022 INRA - TPV URPOI - BIA IMASTE

warning('"lineFit" is deprecated, use "fitLine" instead');


%% Extract input arguments
if length(varargin)==1
    % argument is an array of points
    var = varargin{1};
    x = var(:,1);
    y = var(:,2);   
elseif length(varargin)==2
    var = varargin{1};
    if size(var, 1)==1
        var = varargin{2};
        x = var(:,1);
        y = var(:,2);

    
function line = lineFit(varargin)
%LINEFIT Fit a straight line to a set of points.
%
%   Note: deprecated. Replaced by 'fitLine'.
%
%   L = lineFit(X, Y)
%   Computes parametric line minimizing square error of all points (X,Y).
%   Result is a 4*1 array, containing coordinates of a point of the line,
%   and the direction vector of the line, that is  L=[x0 y0 dx dy];
%
%   L = lineFit(PTS) 
%   Gives coordinats of points in a single array.
%
%   L = lineFit(PT0, PTS);
%   L = lineFit(PT0, X, Y);
%   with PT0 = [x0 y0], imposes the line to contain point PT0.
%
%   Requires:
%   Optimiaztion toolbox
%
%   See also 
%   lines2d, polyfit, polyfit2, lsqlin
%

% ------
% Author: David Legland 
% E-mail: david.legland@inrae.fr
% Created: 2004-04-30
% Copyright 2004-2022 INRA - TPV URPOI - BIA IMASTE

warning('"lineFit" is deprecated, use "fitLine" instead');


%% Extract input arguments
if length(varargin)==1
    % argument is an array of points
    var = varargin{1};
    x = var(:,1);
    y = var(:,2);   
elseif length(varargin)==2
    var = varargin{1};
    if size(var, 1)==1
        var = varargin{2};
        x = var(:,1);
        y = var(:,2);
    else
        % two arguments : x and y
        x = var;
        y = varargin{2};
    end