필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
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.

채택된 답변

Mathieu NOE
Mathieu NOE 2020년 12월 10일
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))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Seismology에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by