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: apcal.m
    path of file: ./repos/hashing-baseline-for-image-retrieval/Method-SELVE
    
    the code of the file until where you have to start completion: function ap = apcal(score,label,labelvalue)
% ap=apcal(score,label)
% average precision (AP) calculation 

    
function ap = apcal(score,label,labelvalue)
% ap=apcal(score,label)
% average precision (AP) calculation 
% input: 
%  score - 1xn vector 
%  label - 1xn vector
%  labelvalue - value of true positives in the 'label' vector
% output: ap
if length(score)~=length(label)
    error('score and label must be equal length\n');
    pause;
end