Retracting the time-tags from the histcounts

4 次查看(过去 30 天)
A histogram (number of time-tags per unit bin) was created using "histcoounts" for a series of time-tags (first picture). After creating histogram, I put the threshold (300) on the count such that the values below the 300 shall get deleted. And the time-tags should be retractable for those values that were above the threshold. Could you please help me with getrting the values of time-tags from the second picture?
  1 个评论
Dyuman Joshi
Dyuman Joshi 2024-2-15
You can use the max() function -
y = 1:10
y = 1×10
1 2 3 4 5 6 7 8 9 10
thresh = 5;
z = max(y, thresh)
z = 1×10
5 5 5 5 5 6 7 8 9 10

请先登录,再进行评论。

回答(2 个)

Dyuman Joshi
Dyuman Joshi 2024-2-15
If you are working with R2019a or a later version, use readmatrix and writematrix. Otherwise, use writetable
D=readmatrix('timetags.txt');
%transposing as histcounts() returns a row vector
D1=histcounts(D, 'NumBins', 200).';
subplot(2,1,1);
plot(D1)
subplot(2,1,2);
D2=D1;
D2(D2<300)=[];
plot(D2)
%write data to a text file
writematrix(D2, 'tagtime.txt')
%check the contents of the file
type tagtime.txt
305 381 588 675 498 505 437 574 427 443 831 444 1134 418 406 376 337 366 383 369 602 1053 337 338 377 417 384 343 388 321 325 363 359 446 1088 397 300 304 333 566 524 438 387 432 355 1067 306 604 673 509 519 469 448 329 1027 855 325 896 712 733 354 331 408 578 786 640 311 307
  8 个评论
Manoj Kumar V
Manoj Kumar V 2024-2-17
Yes. I could not find the timetags values as output.

请先登录,再进行评论。


Image Analyst
Image Analyst 2024-2-15
Try setting those counts to nan. Then they won't show up. Something like
data = 5000 * rand(1, 5000);
subplot(1, 2, 1);
[counts, binEdges] = histcounts(data);
plot(binEdges(1:end-1), counts, 'b-')
yline(300, 'r-')
counts(counts <= 300) = nan;
subplot(1, 2, 2)
plot(binEdges(1:end-1), counts)
grid on;
  3 个评论
Alexander
Alexander 2024-2-15
移动:Dyuman Joshi 2024-2-15
Could you supply the data and code for your picture above?
Manoj Kumar V
Manoj Kumar V 2024-2-15
移动:Dyuman Joshi 2024-2-15
Data (in txt format) and matlab code are attached below.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by