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

4 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Mathieu NOE
Mathieu NOE le 10 Déc 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))

Plus de réponses (0)

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by