%Measuring directional characteristics of sound sources
%Made by Benjamin Nimmerrichter 2022/23 for BUT

wrap = false;
theta = deg2rad(in(2,:));
rho = maxSpl*in(3,:);

clf
%end
angle = (max(theta)-min(theta));

pol_ax = polaraxes('ThetaZeroLocation','top'); %0 degrees on top
%pol_ax = gca;
pol_ax.FontName = 'Times New Roman';

%%saveas(gcf,"MEASUREMENT\charakteristika.png") %save graph to PNG
text = "Polar plot of sound pressure level";
title(text,'interpreter','latex')

pol_ax.RAxis.Label.String = 'dB(SPL)';

pol_ax.RAxis.Label.Interpreter = "latex";

set(pol_ax,"FontSize",21)
rlim([0 maxSpl]);
if (angle <=pi) %half circle
    thetalim([-90 90])
    thetaticks(-90:10:90)
else %full circle
    thetalim([-180 180])
    thetaticks(-180:10:180)
end
polaraxes(pol_ax)


hold on
if (wrap == true) %wraparound
    theta(size(in(2,:))+1) = theta(1);
    rho(size(in(2,:))+1) = rho(1);   
end
    p = polarplot(theta,rho);
    p.LineWidth = 1.5;
hold off