calculate the mode with tolerance
3 次查看(过去 30 天)
显示 更早的评论
I have a matrix A= [ 2 3 2.1 ; 8.1 3.3 2.05 ; 3.01 4.9 2.09] and I want to get the mode with a tolerance of 0.1 there is any way to get this??? to work in matlab with mode (the value most repeated) and tolerance thanks
0 个评论
回答(1 个)
Jan
2017-3-3
The question is not trivial. What do you expect as result for:
x = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
?
You can round the values:
AA = round(A, 1)
and apply mode() afterwards, but this must not be necessarily, what you want.
1 个评论
Sai Sunku
2020-3-20
One can bin the data with the required tolerance and return the center of the bin with the highest frequency. I'm not particular about the tolerance, so I'm doing it as follows:
[N, edges] = histcounts(data);
[~, idx] = max(N); mode = (edges(idx) + edges(idx + 1))/2;
It would be nice if there was a built-in function for this.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!