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: discretesample.m
    path of file: ./repos/libDirectional/lib/util
    
    the code of the file until where you have to start completion: function samples = discretesample(p, n)
    % Obtains samples from discrete distribution given by p
    %
    % Parameters:
    %   p (row or column vector)
    %       propability for each discrete possibility (need not be
    %       normalized)

    
function samples = discretesample(p, n)
    % Obtains samples from discrete distribution given by p
    %
    % Parameters:
    %   p (row or column vector)
    %       propability for each discrete possibility (need not be
    %       normalized)
    %   n (integer > 0)
    %       number of samples
    arguments
        p double {mustBeNonnegative}
        n (1,1) double {mustBePositive,mustBeInteger}
    end