1
0

sphear_bf_plot.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. %%
  2. %% *SpHEAR Project
  3. %%
  4. %% sphear_bf_plot: plot the polar response of a B format signal
  5. %%
  6. %% usage:
  7. %% [BF] = sphear_bf_plot(BF, fmin, fmax)
  8. %%
  9. %% BF: B format signal array
  10. %% fmin, fmax: range of frequencies to consider (to title plot)
  11. %%
  12. %% Copyright Fernando Lopez-Lezcano 2016
  13. %% nando@ccrma.stanford.edu
  14. %%
  15. %% This program is free software: you can redistribute it and/or modify
  16. %% it under the terms of the GNU General Public License as published by
  17. %% the Free Software Foundation, either version 3 of the License, or
  18. %% (at your option) any later version.
  19. %%
  20. %% This program is distributed in the hope that it will be useful,
  21. %% but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. %% GNU General Public License for more details.
  24. %%
  25. %% You should have received a copy of the GNU General Public License
  26. %% along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. function [BF] = sphear_bf_plot(BF, fmin, fmax, rmax)
  28. pkg load signal;
  29. %% to close the polar plots we repeat the first point
  30. m = size(BF, 1);
  31. BF(m + 1,:) = BF(1,:);
  32. theta = (0:m)*(2*pi/m);
  33. %% plot it as a function of angle
  34. bname = cellstr(['W'; 'X'; 'Y'; 'Z']);
  35. f = figure;
  36. for b = 1:4
  37. subplot(2, 2, b);
  38. hold on;
  39. axis square;
  40. axis([-rmax, rmax, -rmax, rmax]);
  41. title([char(bname(b)) ": " sprintf("%05.0d", fmin) " to " sprintf("%05.0d", fmax) " Hz"]);
  42. [xr, yr] = pol2cart(theta', ones(m + 1,1));
  43. plot(xr, yr);
  44. [x, y] = pol2cart(theta', abs(BF(:,b)));
  45. plot(x, y, '.-r', 'LineWidth', 0.5);
  46. end
  47. print(f, '-dpng','-color',["figures/sphear_polar_multi_" sprintf("%05d", fmin) "_" sprintf("%05d", fmax) ".png"]);
  48. end