histogram of x and y data from a txt file

10 visualizaciones (últimos 30 días)
masoud meskin
masoud meskin el 29 de Nov. de 2021
Comentada: Star Strider el 29 de Nov. de 2021
Hi guys!
The attached txt file contains the infromation of mesh quality generated in a CAD model. The 1st column represents the "skewness" and the 2nd column represents the "number of elements". How i can plot the histogram of the data, in which the x axis shows the skewness and y axis shows the number of elements, like the attached figure?
Thank you
Masoud

Respuesta aceptada

Star Strider
Star Strider el 29 de Nov. de 2021
It seems to produce the correct result on its own!
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/817474/mesh_histogram.txt', 'VariableNamingRule','preserve')
T1 = 400×2 table
Var1 Var2 ________ ____ 0.024316 0 0.024316 1 0.033988 1 0.033988 0 0.033988 0 0.033988 0 0.04366 0 0.04366 0 0.04366 0 0.04366 4 0.053332 4 0.053332 0 0.053332 0 0.053332 139 0.063005 139 0.063005 0
figure
plot(T1{:,1}, T1{:,2})
Adjust the available options to produce the desired result.
Another possibility —
figure
fill(T1{:,1}, T1{:,2}, 'r')
Experiment to get the desired result.
.
  2 comentarios
masoud meskin
masoud meskin el 29 de Nov. de 2021
Editada: masoud meskin el 29 de Nov. de 2021
OMG! i didn't even try to plot it. I started with histogram(x) function and i got confused.
By the way, thank you for the help.
Star Strider
Star Strider el 29 de Nov. de 2021
As always, my pleasure!
.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 29 de Nov. de 2021
Looks like Star's answer is what you're looking for. I just wanted to say that skewness is the third central moment of a distribution (histogram), so that histogram you have will also have a skewness related to how lopsided/skewed the distribution is. A symmetrical distribution (e.g. a Normally distributed population) would have a skewness of 0. If it's skewed left it would have a negative skewness and if it's skewed right it would have a positive skewness.
I've heard of the skewness of a histogram but I've never heard of a histogram of skewnesses, though it's possible. For example you could read in 400 images and compute the distance between an actual (x,y,z) coordinate on the 3-D printed (or blow molded) physical object, and the desired (x,y,z) coordinate of the CAD model, and then get a histogram of the distances and compute the skewness of the disance errors for each image (CAD file) (based on it's histogram), then you could get a distribution of those skewnesses (over all CAD files), where the bin value is the skewness and the y value is the count.
What's puzzling me is that none of your skewnesses are more than 1, or less than 0. I mean, I guess it could happen, like if your distributions were just very slightly lopsided to the right, though the huge spikes near (but not exactly at) 1 are also puzzling.
So I just wanted to make sure that you're getting your skewnesses correct and you really have a distribution of skewnesses and not some other type of distribution, like distribution of gray levels, or particle sizes, or distance deviations between physical model and CAD model, or whatever.
  2 comentarios
masoud meskin
masoud meskin el 29 de Nov. de 2021
Thank you so much for the generous help. This skewness is an indicator of the quality of the grids (mesh elements) used in finite element, finite volume or finite difference mthods to estimate the solutions of partial differential equations. it is the result of and that's why its value is between 0 and 1. So the mesh elements with skewness value close to 1 have optimal quality and below 0.1 have poor quality. https://en.wikipedia.org/wiki/Types_of_mesh
But let me use this opportunity to ask what is your opinion about this histogram? i say because the histogram has a short thin tail and it is skewed to right, it indicates that the quality of the mesh is good. Do you have further observations?
Image Analyst
Image Analyst el 29 de Nov. de 2021
Seems to me "perfect" would be if the cellsize was the optimalcellsize so the numerator was 0 and the skew value would be 0, not 1. If the cell size was 0, it seems like that would be bad and the skew would be 1, and if the cell size was huge, like 2*optimalcellsize, then the skew would be -1. So it seems like a histogram might have a hump centered around zero if most of the cell sizes were near optimal.

Iniciar sesión para comentar.

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by