view Functions/percCorr.m @ 0:ab043bd3b162 tip

First commit
author Alice Clifford <alice.clifford@eecs.qmul.ac.uk>
date Mon, 11 Jun 2012 17:42:13 +0100
parents
children
line wrap: on
line source
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;