1
0

sphear_wxyz_plot.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. %%
  2. %% *SpHEAR Project
  3. %%
  4. %% sphear_wxyz_plot: plot the polar response of a B format signal in a frequency range
  5. %%
  6. %% usage:
  7. %% 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 sphear_wxyz_plot(BF, fmin, fmax, rmax)
  28. if (!exist("plot_on"))
  29. plot_on = "epsc";
  30. else
  31. if (plot_on == 1)
  32. plot_on = "epsc"
  33. end
  34. end
  35. %% to close the polar plots we repeat the first point
  36. m = size(BF, 1);
  37. n = 32;
  38. BF(m + 1,:) = BF(1,:);
  39. theta = (0:m)*(2*pi/m);
  40. thetaf = (0:n)*(2*pi/n);
  41. %% plot it as a function of angle
  42. bname = cellstr(['W'; 'X'; 'Y'; 'Z']);
  43. f = figure;
  44. for b = 1:4
  45. subplot(2, 2, b);
  46. hold on;
  47. grid off;
  48. axis square;
  49. axis([-rmax, rmax, -rmax, rmax]);
  50. ca=get (gcf, "currentaxes");
  51. set(ca,"fontweight","bold","linewidth",1.5)
  52. title([char(bname(b)) ": " sprintf("%05.0d", fmin) " to " sprintf("%05.0d", fmax) " Hz"]);
  53. if (strcmp(plot_on, "epsc") || strcmp(plot_on, "pngc"))
  54. %% color plot
  55. dopts = '.-r';
  56. ropts = '-b';
  57. copt = '-color';
  58. cext = "_color";
  59. else
  60. %% mono plot
  61. dopts = '.-';
  62. ropts = '-';
  63. copt = '-mono';
  64. cext = "_mono";
  65. end
  66. grey = [0.1, 0.1, 0.1];
  67. %% radius circles
  68. for rad = 0.25:0.25:rmax
  69. [xr, yr] = pol2cart(thetaf', ones(n + 1,1) * rad);
  70. plot(xr, yr, ':', 'Color', grey);
  71. end
  72. %% radial lines
  73. for ang = theta
  74. plot([0 rmax*cos(ang)], [0 rmax*sin(ang)], ':', 'Color', grey);
  75. end
  76. [xr, yr] = pol2cart(thetaf', ones(n + 1,1));
  77. plot(xr, yr, ropts);
  78. [x, y] = pol2cart(theta', abs(BF(:,b)));
  79. plot(x, y, dopts, 'linewidth', 1.5, 'markersize', 6);
  80. end
  81. print(f, '-deps','-tight',copt,["figures/sphear_polar_multi_" sprintf("%05d", fmin) "_" sprintf("%05d", fmax) cext ".eps"]);
  82. end