function [percHits]=percCorr(in,delay,err)
%calculate percentage of values in an array are within a defined value with
%an error
% Input:
%   - in: vector to test
%   - delay: correct value
%   - err: error +/-
%
% Output:
%   - percHits: percentage of correct values
%
% Developers:  - Alice Clifford (alice.clifford@eecs.qmul.ac.uk)


y=zeros(length(in),1);

for n=1:length(in);
    
    for k=-err:err
        if in(n)==delay+k
            y(n)=1;
        end
    end
end

y=y(y==1);


numHits=length(y);

percHits=(numHits/length(in))*100;
