sphear_bf_plot.m 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. %%
  14. function [BF] = sphear_bf_plot(BF, fmin, fmax, rmax)
  15. pkg load signal;
  16. %% to close the polar plots we repeat the first point
  17. m = size(BF, 1);
  18. BF(m + 1,:) = BF(1,:);
  19. theta = (0:m)*(2*pi/m);
  20. %% plot it as a function of angle
  21. bname = cellstr(['W'; 'X'; 'Y'; 'Z']);
  22. f = figure;
  23. for b = 1:4
  24. subplot(2, 2, b);
  25. hold on;
  26. axis square;
  27. axis([-rmax, rmax, -rmax, rmax]);
  28. title([char(bname(b)) ": " sprintf("%05.0d", fmin) " to " sprintf("%05.0d", fmax) " Hz"]);
  29. [xr, yr] = pol2cart(theta', ones(m + 1,1));
  30. plot(xr, yr);
  31. [x, y] = pol2cart(theta', abs(BF(:,b)));
  32. plot(x, y, '.-r', 'LineWidth', 0.5);
  33. end
  34. print(f, '-dpng','-color',["figures/sphear_polar_multi_" sprintf("%05d", fmin) "_" sprintf("%05d", fmax) ".png"]);
  35. end