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: convFilterSD.m
    path of file: ./repos/OPTI/Utilities/opti
    
    the code of the file until where you have to start completion: function mprob = convFilterSD(prob,opts)
%CONVFILTERSD Convert OPTI problem to FilterSD Nonlinear problem
%
%   mprob = convFilterSD(prob,opts)

%   Copyright (C) 2013 Jonathan Currie (Control Engineering)

%Ensure all args passed
if(nargin < 2)
    error('You must supply both the problem + options');
end
if(~isstruct(prob) || ~isstruct(opts))
    error('Both prob + opts must be structures!');
end

%Make sure we have an NLP
if(~any(strcmpi(prob.type,{'NLP','UNO'})))
    error('You can only convert UNOs and NLPs to FILTERSD format!');
end

%Get Warning Level
if(strcmpi(op
    
function cannot continue.\n\nPlease provide x0 to optiprob / opti in order to solve this problem.']);
    error(str); %#ok<SPERR> it doesn't take \n!
end       

%Check obj + grad functions are ok (may segment error otherwise!)
try
    f = prob.fun(x0);  %#ok<NASGU>
catch ME
    fprintf(2,'There was an error when running a test objective function call. Please ensure this function exists and runs without error.\n\n');
    rethrow(ME);
end
if(isempty(prob.f))
    error('The gradient function is empty. Please rebuild the OPTI object specifying FilterSD as the solver');
end
try
    g = prob.f(x0); %#ok<NASGU>
catch ME
    fprintf(2,'There was an error when running a test gradient function call. Please ensure this function exists and runs without error.\n\n');
    rethrow(ME);
end

%Objective Callback Functions
mprob.fun = prob.fun;
mprob.grad = prob.f;

%Constraint Callback Functions
if(~isempty(prob.nlcon))
    %Test constraint function
    try
        g = prob.nlcon(x0); %#ok<NASGU>
    catch ME
        fprintf(2,'There was an error when running a test Constraint function call. Please ensure this function exists and runs without error.\n\n');
        rethrow(ME);
    end    
    %Get sample jacobian back
    try
        testJ = prob.nljac(x0);
    catch ME
        fprintf(2,'There was an error when running a test Jacobian function call. Please ensure this function exists and runs without error.\n\n');
        rethrow(ME);
    end
    %Check for sparse Jacobian
    if(issparse(testJ))
        %Check for Jac Structure
        if(isempty(prob.nljacstr))
            if(warn > 1)
                optiwarn('opti_filtersd:jacstr','Conv FILTERSD - You have not supplied the Jacobian Structure of the Constraints, Assuming ones(m,n)');
            end
            %Assume all ones
            Jstr = sparse(ones(length(prob.cl),length(x0)));
            mprob.nljacstr = @() Jstr;
        else
            %Get sample jacobian structure back
            try
                testJstr = prob.nljacstr();
            catch ME
                fprintf(2,'There was an error when running a test Jacobian structure function call. Please ensure this function exists and runs without error.\n\n');
                rethrow(ME);
            end