What is wrong with my approach to building this histogram?
16 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Steven Lord
on 18 Nov 2024 at 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 Comments
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!