Plotting Normal distribution ( Bell shaped )Histogram with weight Percentage in Y axis and grain diameter in X axis
10 views (last 30 days)
Show older comments
How to Plot Normal distribution ( Bell shaped )Histogram with weight Percentage in Y axis and grain diameter in X axis as in attched snapshot .
Thanks
Narayan
0 Comments
Answers (1)
Divyam
on 10 Sep 2024
It appears that the image attached is plotting the deviation of grain diameter from a certain value. Assuming that the deviation is measured with respect to the mean, here the implementation for your requirements.
% Sample data: grain diameters
grain_diameters = 50 + 10 * randn(1000, 1);
% Calculate the mean of the grain diameters
mean_diameter = mean(grain_diameters);
std_diameter = std(grain_diameters);
% Calculate the deviation from the mean
deviation_from_mean = grain_diameters - mean_diameter;
% Plot histogram of the deviations
histogram(deviation_from_mean);
% Add labels and title
xlabel('Deviation in Grain Diameter wrt Mean');
ylabel('Weight Percentage');
title('Histogram of Grain Diameter Deviations');
% Remove xtick labels and get the values of xticks
set(gca,'xticklabel', [])
xTicks = get(gca, 'xtick');
% Store the value of the desired xtick label in the cell array XTickString
for iXTick = 1:length(xTicks)
XTickString{iXTick} = ['$$\begin{array}{c}' num2str(xTicks(iXTick)) 'mm\\' ...
num2str(xTicks(iXTick)/std_diameter) '\sigma\\' '\end{array}$$'];
end
% Set the value for xtick label to the cell array and use the latex
% interpreter to effectively display the desired results
set(gca,'XTickLabel',XTickString,'TickLabelInterpreter','latex');
For more information on multiline "xtick" labels, refer to this MATLAB Answer: https://www.mathworks.com/matlabcentral/answers/101922
0 Comments
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!