histogram of x and y data from a txt file
9 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Star Strider
2021-11-29
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')
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 个评论
更多回答(1 个)
Image Analyst
2021-11-29
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 个评论
Image Analyst
2021-11-29
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!