Creating a polar histogram with x values (bins) that will appear on the graph even though no values fall into those bins?
7 views (last 30 days)
Show older comments
James Baldassano
on 31 May 2023
Commented: James Baldassano
on 31 May 2023
I am trying to make a polar histogram of values that actually are measured angles of axons exiting a brain structure (they are all measured in 2D). Essentially, these angles are all roughly between 1-270 degrees, but there are no measurements between 270 & 360. I have attached a histogram made of the data. My goal is to essentially "wrap" this histogram around a circle, but since there are no values for the last 1/4 of the x values, I'm not sure how to tell MATLAB that "there needs to be an empty section on this histogram at the end."
Thank you!
0 Comments
Accepted Answer
Steven Lord
on 31 May 2023
x = deg2rad(randi([0 270], 1, 1e6));
polarhistogram(x);
If not, just call histogram with a vector of bin edges and/or specifying the BinLimits name-value argument.
x = rand(1, 1e6);
h = histogram(x, 0:0.25:2);
h.BinEdges.'
Even though there's no data greater than 1, because I specified the bin edges that's what histogram used.
figure
h = histogram(x, 'NumBins', 16, 'BinLimits', [0 2]);
h.BinEdges.'
16 equal width bins spanning from 0 to 2.
More Answers (0)
See Also
Categories
Find more on Annotations 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!