histfit function - how to create one bin for each unique value?
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 2 Apr 2021
Did you try
edges = [unique(yourData(:)), inf];
theHistogram = histogram(yourData, edges);
See Also
Categories
Find more on Bar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!