What is wrong with my approach to building this histogram?
16 次查看(过去 30 天)
显示 更早的评论
I am working on a project that builds a histogram based on the data selected by the user in the program. I am facing an issue with how my histogram is built. I use the code below to build it. 'Theta' there is one of the possible data arrays that can be selected. The histogram on the left is built using my approach. However, it should look like the one on the right. What am I doing wrong and how can I revise my approach to building it? Edit: I have to add that 'Theta' contains the azimuth changes of the wind direction measured at a weather station. So I suppose this might play a part why my histogram is not correct.
theta=[236 239 154 237 267 107 102 103 95 104 101 110 94 99 97 97 118 123 115 123 94 96 119 101]
p = polarhistogram(theta,16);
ax = gca;
ax.ThetaLim = [0 360];
ax.ThetaTickLabel = {'E','NE', 'N', 'NW', 'W', 'SW', 'S', 'SE'};
ax.ThetaTick = (0:45:360);
0 个评论
回答(1 个)
Steven Lord
2024-11-18,15:47
From the documentation for the polarhistogram function: "polarhistogram(theta) creates a histogram plot in polar coordinates by sorting the values in theta into equally spaced bins. Specify the values in radians." [Emphasis added.]
theta=[236 239 154 237 267 107 102 103 95 104 101 110 94 99 97 97 118 123 115 123 94 96 119 101];
p = polarhistogram(deg2rad(theta),16);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!