Find Optimal Threshold for Waveform (Decibel) Data
1 次查看(过去 30 天)
显示 更早的评论
I have 2 sets of data that I need to use thresholds for in order to evaluate the data. These two data sets are waveform data (data values in -dB) and contain noise that must be eliminated (timestamps also available for this data). For set 1, the threshold is known; for set 2, the threshold is unknown and is the reason for this question. The object of the needed code is to find the best threshold that provides the smallest difference in signal count (in other words, not noise) for the entirety of both sets of data.
Here is what I have right now for code, which I know is only half correct (doesn't take into account continual minimal difference, only minimal count difference at the end of each data set):
function [threshold, difference, bestThreshold, bestDifference] = ThresholdFinder(dBdata1, data1Time, dBdata2, data2Time, StartRange, EndRange)
signalCount1=double.empty;
signalCount2=double.empty;
%The following process filters out noise for dBdata1 since the threshold for this data set is known.
sig1instances = (dBdata1 > -70);
sig1signals = dBdata1(sig1instances);
sig1times = data1Time(sig1instances);
%Get the signal count for dBdata1
for b=1:1:numel(sig1times)
signalCount1(b)=b;
end
a=0;
difference=double.empty;
threshold=double.empty;
%note that the accuracy of the waveform values is .001
for d=StartRange:.001:EndRange;
a=a+1;
%The following process filters out noise
sig2instances = (dBdata2 > -d);
sig2signals = dBdata2(sig2instances);
sig2times = data2Time(sig2instances);
for c=1:1:numel(sig2times)
signalCount2(c)=c;
end
%this right here is what is wrong:
difference(a)=max(abs(numel(sig1times)-numel(sig2times)));
threshold(a)=-d;
%instead of above, I need to take take into consideration each difference that is paired with each count for each threshold between the given range, then find the pair that has the consistently least difference in signal counts throughout the entirety of the waveform data sets.
end
plot(threshold, difference);
xlabel('Threshold (Negative dB)');
ylabel('Count Difference');
str = sprintf('Threshold vs. Count Difference\n');
%this char array allows us to print on multiple lines for the title
title(str);
[bestDifference oIndex] = min(difference);
bestThreshold = threshold(oIndex);
Yes, I know this is complex, but it is easier to solve problems like this when there is more than one person approaching the problem. Any help is much appreciated. Thank you.
0 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!