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: lineintersect.m
    path of file: ./repos/Chess-Board-Recognition/Code
    
    the code of the file until where you have to start completion: function [x,y]=lineintersect(l1,l2)
%This function finds where two lines (2D) intersect
%Each line must be defined in a vector by two points
%[P1X P1Y P2X P2Y], you must provide two has arguments
%Example:
%l1=[93 388 120 354];
%l2=[102 355 124 377];
%[x,y]=lineintersect(l1,l2);
%You can draw the lines to confirm if the solution is correct
%figure
%clf
%hold on
% line([l1(1) l1(3)],[l1(2) l1(4)])
% line([l2(1) l2(3)],[l2(2) l2(4)])
% plot(x,y,'ro') %this will mark the intersection point
%
%There is also included in another m file the Testlineintersect
%That m file can be used to input the two lines interactively
%
%Made by Paulo Silva
%22-02-2011

%default values for x and y, in case of error these are the outputs
x=nan;
y=nan;


    
function [x,y]=lineintersect(l1,l2)
%This function finds where two lines (2D) intersect
%Each line must be defined in a vector by two points
%[P1X P1Y P2X P2Y], you must provide two has arguments
%Example:
%l1=[93 388 120 354];
%l2=[102 355 124 377];
%[x,y]=lineintersect(l1,l2);
%You can draw the lines to confirm if the solution is correct
%figure
%clf
%hold on
% line([l1(1) l1(3)],[l1(2) l1(4)])
% line([l2(1) l2(3)],[l2(2) l2(4)])
% plot(x,y,'ro') %this will mark the intersection point
%
%There is also included in another m file the Testlineintersect
%That m file can be used to input the two lines interactively
%
%Made by Paulo Silva
%22-02-2011

%default values for x and y, in case of error these are the outputs
x=nan;
y=nan;

%test if the user provided the correct number of arguments
if nargin~=2
disp('You need to provide two arguments')
return
end