1
0

capsule_plot.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. %%
  2. %% *SpHEAR Project
  3. %%
  4. %% capsule_plot: plot the polar response of a capsule
  5. %%
  6. %% usage:
  7. %% capsule_plot(R, fmin, fmax)
  8. %%
  9. %% R: capsule response in frequency range
  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 capsule_plot(i, R, fmin, fmax, rmax, col)
  28. m = size(R, 1);
  29. n = 32;
  30. theta = (0:m-1)*(pi/(m-1));
  31. thetaf = (0:n)*(pi/n);
  32. hold on;
  33. axis([-rmax, rmax, 0, rmax], "equal", "tickx");
  34. title(["EM182 polar pattern"]);
  35. if (i == 1)
  36. grey = [0.1, 0.1, 0.1];
  37. %% radius circles
  38. for rad = 0.25:0.25:rmax
  39. [xr, yr] = pol2cart(thetaf', ones(n + 1,1) * rad);
  40. plot(xr, yr, ':', 'Color', grey);
  41. end
  42. %% radial lines
  43. for ang = theta
  44. plot([0 rmax*cos(ang)], [0 rmax*sin(ang)], ':', 'Color', grey);
  45. end
  46. end
  47. [x, y] = pol2cart(theta', abs(R(:)));
  48. p = plot(x, y, [".-;" sprintf("%d to %d Hz", fmin, fmax) ";"], 'LineWidth', 0.5);
  49. set(p, 'color', col);
  50. end