Advertisement
makispaiktis

Course 5 - Visualize earthquake peaks

Sep 3rd, 2023 (edited)
1,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.80 KB | None | 0 0
  1. clear all
  2. close all
  3. clc
  4.  
  5. % 1. Power in dB from [p, f, t] = [power, frequency, time]
  6. load after_filtering
  7. [p, f, t] = pspectrum(wanc_bandpass,50,"spectrogram")
  8. psum = sum(p);
  9. plot(t, psum)
  10. pwr = db(psum, "power")
  11. plot(t, pwr)
  12.  
  13. % 2. Local extrema live task - Find local maxima here
  14. maxIndices = islocalmax(pwr,"MinProminence",10,"SamplePoints",t);
  15. figure
  16. plot(t,pwr,"Color",[77 190 238]/255,"DisplayName","Input data")
  17. hold on
  18. plot(t(maxIndices),pwr(maxIndices),"^","Color",[217 83 25]/255,...
  19.     "MarkerFaceColor",[217 83 25]/255,"DisplayName","Local maxima")
  20. title("Number of extrema: " + nnz(maxIndices))
  21. hold off
  22. legend
  23. xlabel("t")
  24.  
  25. % 3. Visualize earthquakes
  26. quakeSec = t(maxIndices)
  27. tvec = (0:numel(wanc_bandpass)-1)/50;
  28. plot(tvec,wanc_bandpass)
  29. xline(quakeSec)
  30. xlabel("Time (seconds)")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement