MATLAB Answers

0

Histogram with circular bars

Asked by Joanna Smietanska on 10 Oct 2019
Latest activity Answered by Bjorn Gustavsson on 10 Oct 2019
Hi, I have data grouped into 100x3 and 100x4 matrices. Each matrix column refers to different types of measured angles, e.g. alpha, beta and so on. I prepared single polar histogram for first angle:
A = [160 65 200; 145 75 225; 160 50 250; 120 70 220]; % shortened version of one of 3-column matrices
[N, bin] = histcounts(A(:,1), 10, 'Normalization','probability');
minData = min(min(N));
maxData = max(max(N));
f = figure;
p1 = polarhistogram(A(:,1),10, 'Normalization','probability','FaceColor', 'b');
colorbar;
caxis([minData maxData]);
How can I plot content of each matrix into one polar probability histogram with concentric bins respective for each angle? I can't find out how to add other circular bins for subsequent angles. I would like to create something similar to this plot:
I will be very grateful for any advice and help.

  0 Comments

Sign in to comment.

1 Answer

Answer by Bjorn Gustavsson on 10 Oct 2019

I would do something like this:
edges = 0:15:360;
N_all(1,:) = histcounts(M1,edges);% Put one histogram per row into N_all
N_all(2,:) = histcounts(M2,edges);
N_all(3,:) = histcounts(M3,edges);
N_all(4,:) = histcounts(M4,edges);
N_all(5,:) = N_all(4,:); % Replicate the last row
R = 1:5; % some arbitrary radial coordinates
theta = edges*pi/180; % angles in radians
try
polarPcolor(theta*180/pi,R,N_all),shading flat
catch
disp('You can find the polarPcolor function on the file exchange')
[theta,R] = meshgrid(theta,R);
pcolor(R.*cos(theta),R.*sin(theta),N_all),shading flat
end
HTH

  0 Comments

Sign in to comment.