MATLAB: How can I put the histfit function in terms of probability

fithisthistfithistogramnormal function

Hi, I am using the histfit function, but I need the y-axis to stay in terms of probability (0-1). how can I do this?

Best Answer

That is not directly possible with histfit, however it is not impossible:
data = randn(1,100)+1; % Create Vector
figure
histfit(data) % Original
hh = histfit(data);
figure
ybar = hh(1).YData;
bar(hh(1).XData, ybar/sum(ybar), 'BarWidth',1) % Probability
hold on
plot(hh(2).XData, hh(2).YData/sum(ybar), 'r', 'LineWidth',2)
hold off
.