histfit function - how to create one bin for each unique value?
4 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to use the histfit function. My goal is to modify the code below so that I can create a bin for each unique value from data in excel (not evenly spaced bins) and then still overlay the fits. Is this possible?
I've attached what the hist would look like (made in graphpad). But, my matlab plots look like those attached.
Thanks!
r = xlsread('Results.csv','B:B')
ax1 = subplot(3,1,1); % Left subplot
h=histfit(ax1,r,33,'inversegaussian')
title(ax1,'Inverse Gaussian')
h(1).FaceColor = [1 0 0]
h(2).Color = [.2 .2 .2];
ax2 = subplot(3,1,2); % Right subplot
h=histfit(ax2,r,33,'Rayleigh')
title(ax2,'Rayleigh')
h(1).FaceColor = [1 0 0]
h(2).Color = [.2 .2 .2];
ax2 = subplot(3,1,3); % Right subplot
h=histfit(ax2,r,33,'Rician')
title(ax2,'Rician')
h(1).FaceColor = [1 0 0]
h(2).Color = [.2 .2 .2];
%pd = fitdist(r,'Normal')
0 个评论
回答(1 个)
Image Analyst
2021-4-2
Did you try
edges = [unique(yourData(:)), inf];
theHistogram = histogram(yourData, edges);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!