% An example to function CD_ALG.m to detect the BZ type of clipped
% points on a waveform.

fid = fopen('demo1.dat','r'); % Waveform data recorded by station
data = fscanf(fid,'%f');      % VO on the E-W component.
fclose(fid);                  % ID= 1999245141524, Mag = 3.4
                              % Epi-distance = 20.27 km

ObsRang = [-83220.7,83218.2]; % Observed Range for VO on the E-W
                              % component (From Table S1)
                              
TH      = 0.60*ObsRang(2);    % Take the 60% of the maximum Observed Range
                              % as the Threshold
                              
[cloc1] = CD_ALG(data,TH); 

plot(data);                   % Mark the detected clipped points
hold on;                      % with red circles
plot(cloc1,0,'ro');
 
