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: contourMatrixToPolylines.m
    path of file: ./repos/matGeom/matGeom/polygons2d
    
    the code of the file until where you have to start completion: function polys = contourMatrixToPolylines(C)
%CONTOURMATRIXTOPOLYLINES Converts a contour matrix array into a polyline set.
%
%   POLYS = contourMatrixToPolylines(C)
%   Converts the contour matrix array, as given as the result of the
%   contourc function, into a set of polylines.
%
%   Example
%     img = imread('circles.png');
%     C = contourc(img, 1);
%     polys = contourMatrixToPolylines(C);
%     imshow(img); hold on;
%     drawPolyline(polys, 'Color', 'r', 'LineWidth', 2);
%
%   See also 
%     polygons2d, contour, contourc

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

% size of the contour matrix array
nCoords = size(C, 2);

% first, compute the number of contours
nContours = 0;

    
function polys = contourMatrixToPolylines(C)
%CONTOURMATRIXTOPOLYLINES Converts a contour matrix array into a polyline set.
%
%   POLYS = contourMatrixToPolylines(C)
%   Converts the contour matrix array, as given as the result of the
%   contourc function, into a set of polylines.
%
%   Example
%     img = imread('circles.png');
%     C = contourc(img, 1);
%     polys = contourMatrixToPolylines(C);
%     imshow(img); hold on;
%     drawPolyline(polys, 'Color', 'r', 'LineWidth', 2);
%
%   See also 
%     polygons2d, contour, contourc

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

% size of the contour matrix array
nCoords = size(C, 2);

% first, compute the number of contours
nContours = 0;
offset = 1;
while offset < nCoords
    nContours = nContours + 1;
    offset = offset + C(2, offset) + 1;
end