简体   繁体   English

建议的直方图函数中的Bin中心-Matlab

[英]Bin centers from recommended histogram function - Matlab

Matlab now recommends to use the histogram in place of hist, however doesn't display an obvious way of finding the bin centers like the previous function. Matlab现在建议使用直方图代替hist,但是没有像以前的函数那样显示一种查找bin中心的明显方法。

My current code that works fine with the hist function: 我当前的代码可以与hist函数正常工作:

figure 数字

[counts171,position171] = hist(image171_reshaped,200); [counts171,position171] = hist(image171_reshaped,200);

plot(position171,log(counts171)); 图(position171,日志(counts171));

How would I be able to transform this piece of code in order to incorporate a recommended function such as 'histogram' or 'histcounts' in place of 'hist', while still obtaining the bin centers? 我如何能够转换这段代码,以结合推荐的功能(例如“直方图”或“ histcounts”)代替“ hist”,同时仍然获得bin中心?

histcounts returns edges instead of bin centers and bin centers are midpoints between consecutive elements of the edges. histcounts返回边缘而不是bin中心,并且bin中心是边缘的连续元素之间的中点。 So using diff function bin centers can be obtained: 因此,使用diff函数可以得到bin中心:

[counts171,edges171] = histcounts(image171_reshaped,200);

position171 = edges171(1:end-1) + diff(edges171) / 2;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM