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: SmoothingPoints2d_Bounds.m
    path of file: ./repos/d2d/arFramework3/PL2D/Subfunctions_autofix
    
    the code of the file until where you have to start completion: function [indxs,indys,dirs,margin] = SmoothingPoints2d_Bounds(lbub,output_msg)

% [indxs,indys,dirs,margin] = SmoothingPoints2d_Bounds(lbub,output_msg)
%
% Finds discontinuities at the boundaries of the 2D-profile by proposing
% parameter steps not in parameter direction, but in data direction. If
% such a proposed step leads to an improved 2dprofile value, there is a
% discontinuity. 
%
% lbub: 1 for upper bound, -1 for lower bound 
% 
% indxs:   Parameter index in ar.ple2d.smooth of discontinuous point
% indys:   Prediction index in ar.ple2d.smooth of discontinuous point
% dirs:    Direction in which correction of profile is necessary
% margin:  Improvement of 2dprofile value over existing value

    
function [indxs,indys,dirs,margin] = SmoothingPoints2d_Bounds(lbub,output_msg)

% [indxs,indys,dirs,margin] = SmoothingPoints2d_Bounds(lbub,output_msg)
%
% Finds discontinuities at the boundaries of the 2D-profile by proposing
% parameter steps not in parameter direction, but in data direction. If
% such a proposed step leads to an improved 2dprofile value, there is a
% discontinuity. 
%
% lbub: 1 for upper bound, -1 for lower bound 
% 
% indxs:   Parameter index in ar.ple2d.smooth of discontinuous point
% indys:   Prediction index in ar.ple2d.smooth of discontinuous point
% dirs:    Direction in which correction of profile is necessary
% margin:  Improvement of 2dprofile value over existing value
%
% This function is in its current state not particularly efficient with
% respect to computational cost, since the amount of local fits performed 
% is about the number of sampled profiles. However, all discontinuities
% found are actually real and not just possibly discontinuous.
% 
% See also: rmProfileJump2d , SmoothingPoints2d_Excess,
% SmoothingPoints2d_Inside

if ~exist('lbub','var') || isempty(lbub)
    fprintf(['\n ERROR SmoothingPoints2d_Bounds: \n Please specify',...
        ' whether lower (lbub = -1) or upper (lbub = 1) is of interest. \n']);
    return
end