Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

ez_spectrogram.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. function [wincent,f,y] = ez_spectrogram(x,Fs,win,overlap)
  2. %WORK IN PROGRESS
  3. %NEED to add averaging and correct scaling for graphs
  4. %Measures and displays a spectrogram using ez_powermeasure and the
  5. %short-time FFT technique with a Hann window. x should be a time series
  6. %(row or column vector), Fs is the sample frequency, win is the length of
  7. %each time window (in samples) and overlap how many samples to move the
  8. %window by each time
  9. %M.W.Self 2014
  10. if nargin < 3
  11. win = round(length(x)./10);
  12. end
  13. if nargin < 4
  14. overlap = round(win/2);
  15. end
  16. %USe a Hann window
  17. HW = 1;
  18. %Calculate how many windows we need
  19. nsamps = length(x);
  20. %start the first window at sample 1 and keep going until we can no longer
  21. %fit a whole window into the remaining time-series
  22. nwins = floor((nsamps-win)./overlap)+1;
  23. clear y
  24. startwin = 1;
  25. wincent = zeros(1,nwins);
  26. for n = 1:nwins
  27. endwin = startwin+win-1;
  28. %y has same dims as x?
  29. [f,y(:,n)] = ez_powermeasure(x(startwin:endwin),Fs,HW);
  30. wincent(n) = (startwin+endwin)/2;
  31. %Shift the window
  32. startwin = startwin+overlap;
  33. end
  34. %Plot
  35. if 0
  36. figure,surf(wincent,f,y),view([0 90]),shading interp
  37. ylim([0 Fs/2])
  38. end
  39. return