# CleanData

## PURPOSE

CLEANDATA

## SYNOPSIS

function cleanx = CleanData(x, rnge, choice, epsilon);

## DESCRIPTION

    CLEANDATA
     Usage:
           cleanx = CleanData(x, rnge, choice, epsilon);

     This function will take in a data set x, a specific portion of that data,
     rnge, and look for any points below (choice = 'below') or above (
     (choice = 'above') the threshold epsilon.  It will then get rid of those
     points and create linearly extrapolated points in their place.  It
     returns the cleaned data set cleanx.

     Note: This function is to be used ONLY when the user knows for a fact that
     spurious points exist in the data set.  It is not very automatic, but
     assures that only KNOWN false points will be removed from the set. In
     order to use this, one must look at a plot of the data to determine the
     portion to look at and the threshold to set.

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- FTrack FTRACK

## SOURCE CODE

    0001 function cleanx = CleanData(x, rnge, choice, epsilon);
    0002
    0003 %CLEANDATA
    0004 % Usage:
    0005 %       cleanx = CleanData(x, rnge, choice, epsilon);
    0006 %
    0007 % This function will take in a data set x, a specific portion of that data,
    0008 % rnge, and look for any points below (choice = 'below') or above (
    0009 % (choice = 'above') the threshold epsilon.  It will then get rid of those
    0010 % points and create linearly extrapolated points in their place.  It
    0011 % returns the cleaned data set cleanx.
    0012 %
    0013 % Note: This function is to be used ONLY when the user knows for a fact that
    0014 % spurious points exist in the data set.  It is not very automatic, but
    0015 % assures that only KNOWN false points will be removed from the set. In
    0016 % order to use this, one must look at a plot of the data to determine the
    0017 % portion to look at and the threshold to set.
    0018
    0019 % Written by Dan Valente
    0020 % 10 November 2006
    0021
    0022 cleanx = x;
    0023 dirtyx = x(rnge);
    0024
    0025 if (strcmp(choice, 'below'))
    0026     goodpoints = find(dirtyx > epsilon);
    0027 elseif (strcmp(choice, 'above'))
    0028     goodpoints = find(dirtyx < epsilon);
    0029 end
    0030
    0031 goodpoints = goodpoints + rnge(1) - 1;
    0032 for i = 1:(length(goodpoints)-1)
    0033     if ((goodpoints(i+1)-goodpoints(i)) ~= 1)
    0034         xf = x(goodpoints(i+1));
    0035         xs = x(goodpoints(i));
    0036         m = (xf-xs)/(goodpoints(i+1)-goodpoints(i));
    0037         count = goodpoints(i);
    0038         while count < goodpoints(i+1)
    0039             cleanx(count) = m*(count-goodpoints(i))+xs;
    0040             count = count+1;
    0041         end
    0042     end
    0043 end
    0044
    0045 return;