sphear_bf_plot_fons.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. %% -*- mode: octave -*-
  2. %%
  3. %% *SpHEAR Project
  4. %%
  5. %% sphear_bf_plot: plot the polar response of a B format signal
  6. %%
  7. %% usage:
  8. %% [BF] = sphear_bf_plot(BF, fmin, fmax)
  9. %%
  10. %% BF: B format signal array
  11. %% fmin, fmax: range of frequencies to consider (to title plot)
  12. %%
  13. %% Copyright Fernando Lopez-Lezcano 2016
  14. %% nando@ccrma.stanford.edu
  15. %%
  16. %% This program is free software: you can redistribute it and/or modify
  17. %% it under the terms of the GNU General Public License as published by
  18. %% the Free Software Foundation, either version 3 of the License, or
  19. %% (at your option) any later version.
  20. %%
  21. %% This program is distributed in the hope that it will be useful,
  22. %% but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. %% GNU General Public License for more details.
  25. %%
  26. %% You should have received a copy of the GNU General Public License
  27. %% along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. function [BF] = sphear_bf_plot_fons(BF, fmin, fmax, rmax)
  29. if (!exist("plot_on"))
  30. plot_on = "epsc";
  31. else
  32. if (plot_on == 1)
  33. plot_on = "epsc"
  34. end
  35. end
  36. %% to close the polar plots we repeat the first point
  37. m = size(BF, 1);
  38. n = 32;
  39. BF(m + 1,:) = BF(1,:);
  40. theta = (0:m)*(2*pi/m);
  41. thetaf = (0:n)*(2*pi/n);
  42. %% plot it as a function of angle
  43. bname = cellstr(['W'; 'X'; 'Y'; 'Z']);
  44. f = figure;
  45. for b = 1:4
  46. subplot(2, 2, b);
  47. hold on;
  48. grid off;
  49. axis square;
  50. axis([-rmax, rmax, -rmax, rmax]);
  51. ca=get (gcf, "currentaxes");
  52. set(ca,"fontweight","bold","linewidth",1.5)
  53. title([char(bname(b)) ": " sprintf("%05.0d", fmin) " to " sprintf("%05.0d", fmax) " Hz"]);
  54. if (strcmp(plot_on, "epsc") || strcmp(plot_on, "pngc"))
  55. %% color plot
  56. dopts = '.-r';
  57. ropts = '-b';
  58. copt = '-color';
  59. cext = "_color";
  60. else
  61. %% mono plot
  62. dopts = '.-';
  63. ropts = '-';
  64. copt = '-mono';
  65. cext = "_mono";
  66. end
  67. grey = [0.1, 0.1, 0.1];
  68. %% radius circles
  69. for rad = 0.25:0.25:rmax
  70. [xr, yr] = pol2cart(thetaf', ones(n + 1,1) * rad);
  71. plot(xr, yr, ':', 'Color', grey);
  72. end
  73. %% radial lines
  74. for ang = theta
  75. plot([0 rmax*cos(ang)], [0 rmax*sin(ang)], ':', 'Color', grey);
  76. end
  77. [xr, yr] = pol2cart(thetaf', ones(n + 1,1));
  78. plot(xr, yr, ropts);
  79. [x, y] = pol2cart(theta', abs(BF(:,b)));
  80. plot(x, y, dopts, 'linewidth', 1.5, 'markersize', 6);
  81. end
  82. print(f, '-deps','-tight',copt,["../figures/sphear_polar_multi_" sprintf("%05d", fmin) "_" sprintf("%05d", fmax) cext ".eps"]);
  83. end