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: imCheckerBoard.m
    path of file: ./repos/matImage/matImage/imFilters
    
    the code of the file until where you have to start completion: function res = imCheckerBoard(img1, img2, varargin)
% Create a checkerboard image from 2 images.
%
%   RES = imCheckerBoard(IMG1, IMG2);
%   IMG1 and IMG2 are two images the same size. The result is a composite
%   image created by selecting tile in each image alternatively.
%
%   RES = imCheckerBoard(IMG1, IMG2, N);
%   Also specifies the number of tile in each direction. Default is 8.
%
%   Example
%       [x y] = meshgrid(0:255, 0:255);
%       res = imCheckerBoard(x, y);
%       imshow(res, []);
%
%   See also
%

% ------
% Author: David Legland
% e-mail: david.legland@inrae.fr
% Created: 2009-05-04,    using Matlab 7.7.0.471 (R2008b)
% Copyright 2009 INRA - Cepia Software Platform.

    
function res = imCheckerBoard(img1, img2, varargin)
% Create a checkerboard image from 2 images.
%
%   RES = imCheckerBoard(IMG1, IMG2);
%   IMG1 and IMG2 are two images the same size. The result is a composite
%   image created by selecting tile in each image alternatively.
%
%   RES = imCheckerBoard(IMG1, IMG2, N);
%   Also specifies the number of tile in each direction. Default is 8.
%
%   Example
%       [x y] = meshgrid(0:255, 0:255);
%       res = imCheckerBoard(x, y);
%       imshow(res, []);
%
%   See also
%

% ------
% Author: David Legland
% e-mail: david.legland@inrae.fr
% Created: 2009-05-04,    using Matlab 7.7.0.471 (R2008b)
% Copyright 2009 INRA - Cepia Software Platform.


%% Initialisations

% default number of tiles in each direction
N = 8;
if ~isempty(varargin)
    N = varargin{1};
end