Multiple histograms and how to measure fwhm?

9 visualizaciones (últimos 30 días)
수환 김
수환 김 el 14 de Dic. de 2021
Comentada: Star Strider el 14 de Dic. de 2021
I have 1 to 144 columns.
I want to draw 144 gaussian histograms fitting according to the column and find the positions of 144 FWHM and Peak.
Each column has a different row size.
What should I do?

Respuesta aceptada

Star Strider
Star Strider el 14 de Dic. de 2021
Try this —
M1 = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/833435/1to10_30s_15mm_diff_pivoted.txt')
M1 = 502×144
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 -59 26 -17 -20 15 -56 59 39 93 93 53 12 -180 -3 -101 -56 -69 -38 21 11 -4 95 69 38 -44 -40 -29 -113 15 30 87 -4 47 -17 -23 -44 148 -65 -91 83 -34 10 -150 7 -4 -68 -47 74 121 -29 179 -37 85 85 61 79 4 177 51 -65 153 -21 -29 -95 -124 18 80 119 -130 58 59 11 55 -17 101 107 -175 -33 -298 -19 48 24 93 71 129 34 75 -23 107 126 -53 -92 61 72 66 -70 -70 84 55 178 -30 -7 44 139 -9 -71 156 158 -28 122 -201 -70 -10 262 124 61 -10 -89 -175 -31 -38 -3 -53 -19 -27 -88 145 27 39 76 338 159 110 -47 46 2 47 -94 -47 -224 -113 -93 15 -18 36 -26 -30 -86 21 -90 89 172 -104 -96 8 -26 -8 68 144 65 -14 11 -51 -50 -11 35 -25 110 -69 -109 -72 27 -29 -58 59 13 62 143 113 16 133 19 -133 -45 43 81 55 64 128 136 -43 204 -27 -52 46 -36 -79 72 33 43 46 -27 37 18 254 -35 17 67 -51 -18 -59 -77 33 54 16 82 -168 -85 -11 38 -56 82 109 -4 251 -89 -186 30 -47 261 -93 -139 93 -75 -25 -76 -162 54 158 130 -121 41 -86 -3 -128 -55 -155 -56 105 134 -112 47 58 72 163 -152 -1 29 55 43 -42 -40 -1 -229 120 -89 48 23 43 -34
% figure
% hold on
% for k = 1:size(M1,2)
% subplot(12,12,k)
% hf{k} = histfit(M1(:,k)); % Distribution Plot
% [pks{k},locs{k},fwhm{k},prm{k}] = findpeaks(hf{k}(2).YData, hf{k}(2).XData);
% pd{k} = fitdist(M1(:,k), 'Normal'); % Parameters
% grid
% title(sprintf('Column #%3d (\\mu = %5.2f, \\sigma = %5.2f FWHM = %7.2f)',k, pd{k}.mu, pd{k}.sigma,fwhm{k}))
% end
figure
hold on
for k = 1:size(M1,2)
subplot(122,2,k)
hf{k} = histfit(M1(:,k)); % Distribution Plot
[pks{k},locs{k},fwhm{k},prm{k}] = findpeaks(hf{k}(2).YData, hf{k}(2).XData);
pd{k} = fitdist(M1(:,k), 'Normal'); % Parameters
grid
title(sprintf('Column #%3d (\\mu = %5.2f, \\sigma = %5.2f FWHM = %7.2f)',k, pd{k}.mu, pd{k}.sigma,fwhm{k}))
end
hold off
figure
hold on
for k = 1:24:size(M1,2)
subplot(3,2,ceil(k/24))
hf{k} = histfit(M1(:,k)); % Distribution Plot
[pks{k},locs{k},fwhm{k},prm{k}] = findpeaks(hf{k}(2).YData, hf{k}(2).XData);
pd{k} = fitdist(M1(:,k), 'Normal'); % Parameters
grid
title(sprintf('Column #%3d (\\mu = %5.2f, \\sigma = %5.2f FWHM = %7.2f)',k, pd{k}.mu, pd{k}.sigma,fwhm{k}))
end
hold off
.
  4 comentarios
수환 김
수환 김 el 14 de Dic. de 2021
I understand what you are saying. thank you.
However, what I want is that when drawing a histogram, the Gaussian fitted graph will be different depending on the bin size.
Therefore, the FWHM and Peak (mean) of the fitting graph will also differ depending on the bin size.I want to know how much the numerical values change according to the bin size.
Star Strider
Star Strider el 14 de Dic. de 2021
However, what I want is that when drawing a histogram, the Gaussian fitted graph will be different depending on the bin size.
The Gaussian (or any other) fit actually had nothing to do with the histogram or bin size. It is entirely independent of it. From the histfit documentation Algorithms section:
  • histfit uses fitdist to fit a distribution to data. Use fitdist to obtain parameters used in fitting.
Therefore, the FWHM and Peak (mean) of the fitting graph will also differ depending on the bin size.I want to know how much the numerical values change according to the bin size.
Again, the bin size of the histogram has nothing to do with the distribution fit. It is only there for convenience, so that the fitted curve can be visually compared to the histogram. It is possible to use the histogram frequencies, bin locations, and nonlinear optimisation functions to fit a Gaussian (or any other distribution) curve to the histogram (this has been a topic of several previous Answers posts, some of which I responded to), however that is not accurate (does not produce the same results as directly calculating the mean and std and using them to draw the curve) and does not produce the same results as directly estimating the parameters using fitdist.
.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by