When the histcounts function is used, data that was not in the original data appears
Mostra commenti meno recenti
My data and code are follows
>> load('data.mat')
>> [ecg_peak_counts, ecgEdges,ecgbinidx] = histcounts(ecg_filterpeak_index, 0:windowsN*Fs:limit*windowsN*Fs);
disp(ecg_peak_counts);
disp("-------------------------ecg_filterpeak_index")
disp(ecg_filterpeak_index)
disp("-------------------------ecgbinidx")
disp(ecgbinidx)
disp("------------------edges")
disp(ecgEdges)
disp(ecgbinidx==1)
disp(ecg_filterpeak_index(10))
ecg_filterpeak_index(ecgbinidx==1)
My data ecg_filterpeak_index is incremented.
The first value of ecg_peak_counts (that is, in the bin from 0 to 2000) is 10, but there are really only nine, and indeed ecgbinidx only has the first nine values of 1, but when I run the line ecg_filterpeak_index(ecgbinidx==1), In addition to the output of the first nine data, there is an additional 0.0008, which is not in ecg_filterpeak_index
Risposta accettata
Più risposte (1)
After reproducing your issue and investigating further, I found that the value at the 71st position in your data, 0.775938595158718, falls into the first bin (0-2000). This causes ecgbinidx == 1 to include this position, displaying an approximate value of 1.0e+03 * 0.0008.
You can verify this with the following code:
load('data.mat')
[ecg_peak_counts, ecgEdges,ecgbinidx] = histcounts(ecg_filterpeak_index, 0:windowsN*Fs:limit*windowsN*Fs);
disp(find(ecgbinidx==1))
This will show the exact indices where ecgbinidx equals 1, helping confirm which values fall into the first bin.
Hope this helps.
1 Commento
Wensor
il 13 Nov 2024
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
