Spectrogram not completely showing from Audio Signal

7 Ansichten (letzte 30 Tage)
David
David am 10 Jul. 2022
Beantwortet: Voss am 10 Jul. 2022
Hello I am trying to produce a linear chirp signal that is three seconds long and has a sampling rate (Fs) of 33600. The initial frequency should be 200 Hz and the final frequency be 12,000 Hz. I created a spectrogam for the audio signal but only part of of the results are shown in the spectrogram. Can you please help me solve this problem I'm having?
Fs = 33600;
dt = 0.001;
t = 0:dt:3;
f0 = 200;
f1 = 12000;
t1 = 3;
A = 1;
x = chirp(t,f0,t1,f1);
soundsc(4*x,1/0.001);
plot(t,x)
%%
spectrogram(x,128,120,128,1e3,'yaxis');
colormap jet
set(gca,'LineWidth',1.2,'FontSize',36);
set(gcf,'Position',[2500 100 1550 800]);
ylim([0 12000]);

Antworten (1)

Voss
Voss am 10 Jul. 2022
You say the sampling rate is 33600 (Hz, presumably), but in fact the code uses a sampling rate of 1000 Hz, which is insufficient to accurately represent a chirp going up to 12000 Hz.
Using Fs = 33600 instead of 1000 seems to give a reasonable result:
Fs = 33600;
dt = 1/Fs;%0.001;
t = 0:dt:3;
f0 = 200;
f1 = 12000;
t1 = 3;
A = 1;
x = chirp(t,f0,t1,f1);
% % soundsc(4*x,1/0.001);
% soundsc(4*x,Fs);
plot(t,x) % A lot more samples now:
% spectrogram(x,128,120,128,1e3,'yaxis');
spectrogram(x,128,120,128,Fs,'yaxis');
colormap jet
set(gca,'LineWidth',1.2,'FontSize',36);
set(gcf,'Position',[2500 100 1550 800]);
ylim([0 12]);%000]); % Units are kHz

Kategorien

Mehr zu Time-Frequency Analysis finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by