Filter löschen
Filter löschen

Stacked spectrogram with months on horizontal axis and frequency on vertical axis

4 Ansichten (letzte 30 Tage)
Hi, u came across a code that plots spectograms here attached and called spectro.m. it shows 8 seismograms stacked vertically. unfortunately, the result it produces is shown in an image attached which is spectro2.png. l would want it to produce an image as shown in spectro.png with Frequency on the y axis and time in months on the x axis whereby each seismograms represents a certain month. Thank you.

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 10 Dez. 2020
hi
this is my suggestion; the spectrogram individual data are "stacked" along the time axis
NB that the frequency content is pretty much the same over the 8 data batches (even the in time display it's the same) , so not much difference can be seen along the 8 monthes
clearvars
close all
clc
mydata = load('mydata.mat');
dt = mydata.dt;
figure
subplot(2,1,1)
plot(dt)
title ('Raw data')
dt = detrend(mydata.dt);
subplot(2,1,2)
plot(dt)
title ('Detrended data')
Fs = 500;
ws = 250;
ov = ws/2;
nfft = 2^nextpow2(length(dt));
s_all = [];
t_all = [];
t_offset = 0;
for i = 1:8
[s, f, t] = spectrogram(dt(:,i), chebwin(ws), ov, Fs);
s_all = [s_all s];
t_all = [t_all t+t_offset];
t_offset = t_all(end);
end
val = 20*log(abs(s_all));
f1 = figure;
i1 = imagesc(t_all, f, val);
xlabel ('Time [s]')
ylabel ('Frequency [Hz]')
c2 = colorbar;
ylabel(c2,'Power/frequency')
nb_of_month = 8;
set(gca,'xtick',linspace(t_all(1),t_all(end),nb_of_month))
month = {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};
xticklabels(month(1:nb_of_month))

Weitere Antworten (0)

Kategorien

Mehr zu Seismology finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by