plot gaussian and standard deviation on my histogram

6 views (last 30 days)
Hi everyone,
I have this code and have plotted the histogram and now want to have gaussian and standard deviation.
can anyone help me please?
figure('Name','A3{1}.BMd_Img_o_part1')
edges= linspace(0,255,21);
histogram(image1, 'BinEdges',edges,'normalization','pdf')

Accepted Answer

Star Strider
Star Strider on 8 Sep 2020
I would use normfit and normpdf, although there are also other options:
image1 = 42*randn(1,1000)+42*3; % Create Data
figure('Name','A3{1}.BMd_Img_o_part1')
edges= linspace(0,255,21);
[muHat,sgHat] = normfit(image1);
pdfplot = normpdf(edges, muHat, sgHat);
figure
histogram(image1, 'BinEdges',edges,'normalization','pdf')
hold on
plot(edges, pdfplot, '-r', 'LineWidth',2)
hold off
.
  14 Comments
Fatemeh Shomal Zadeh
Fatemeh Shomal Zadeh on 9 Sep 2020
Thank you so much , I do really appreciate you efforts.

Sign in to comment.

More Answers (1)

Fatemeh Shomal Zadeh
Fatemeh Shomal Zadeh on 8 Sep 2020
this is a histogram figure that i have.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!