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: build_ptmp_xyt_cov.m
    path of file: ./repos/matlab_owc/matlab_codes
    
    the code of the file until where you have to start completion: 
function cov = build_ptmp_xyt_cov( ptmp,coord_float,po_system_configuration);

% This function was created from build_ptmp_cov  which the description is written below:
% 
% Description of build_ptmp_cov 
% ____
% This function builds the covariance matrix (a square matrix) that has nxn number
% of tiles, each tile is of mxm size.
%
% The vertical covariance matrix is the building tile. It has 1 at its diagonal,
% then decreases exponentially in the off-diagonals, which represents the vertical
% covariance between water masses.
%
% This version assums that each profile is independent from the other ones.
%
% Annie Wong, May 2001
% Breck Owens, November 2007
%____
%
% Cecile Cabanes, June 2013 
% Compared to build_ptmp_cov, build_cov( ptmp,coord_float,po_system_configuration) take into account the horizontal covariance between different mapped profiles. 
% This 
    
function and the large spatial scales
%
% Cecile Cabanes, 2017
% use the small spatial scales instead of the large spatial scales to build
% the lateral covariance: found to be the best compromise between
% informative errors  and large enough NDF for AIC criterium, at least for
% the scales defined for the North Atlantic bassin
% 
% Cecile Canbanes 2020
% the small time scales are also taken into account when building the covariance between different mapped profiles.

% Set up the theta boundaries for water masses

ptboundaries = [ 30; 24; 18; 12; 8; 4; 2.5; 1; -2 ];
ptscale_down = [ 6; 6; 6; 4; 4; 1.5; 1.5; 1; 1 ];
ptscale_up = [ 6; 6; 6; 6; 4; 4; 1.5; 1.5; 1 ];


% set up the building tile = vertical covariance matrix
%
% upper triangle of the matrix = covariance of each ptlevel with every ptlevel below it,
%  looking down the water column from the diagonal
% lower triangle of the matrix = covariance of each ptlevel with every ptlevel above it,
%  looking up the water column from the diagonal

[m,n]=size(ptmp);

cov=zeros(m*n,m); % set up the output covariance matrix, with 1's along the diagonal


for k=1:n % for each profile
    k1 = (k-1)*m;
    for l=1:1 % for each profile
        l1 = (l-1)*m;
        for i=1:m % for all levels
            for j=1:m
                if(i<j) % upper triangle, look down the water column for vertical scale
                    Ltheta = interp1( ptboundaries, ptscale_down, ptmp(i,k), 'linear' );
                    cov(i+k1,j+l1) = exp( - ( ptmp(j,k) - ptmp(i,k) ).^2/ Ltheta.^2 );
                elseif(i>j) % lower triangle, look up the water column for vertical scale
                    Ltheta = interp1( ptboundaries, ptscale_up, ptmp(i,k), 'linear' );
                    cov(i+k1,j+l1) = exp( - ( ptmp(j,k) - ptmp(i,k) ).^2/ Ltheta.^2 );
                elseif(i==j)   
                     cov(i+k1,j+l1) =1;
                end