Clear Filters
Clear Filters

STFT error about segement length more than long input signal

5 views (last 30 days)
oundsource = 'sing.wav';
[y,fs]=audioread(soundsource);
bv = (soundsource(:,1)+soundsource(:,2))/2; % STFT for average
%% SET PARAMETERS for STFT
R = 10000; % R: window length
window = hamming(R); % hamming window, length R
N = 2^16; % N: FFT resolution
L = ceil(R*0.5); % L: number of non-overlap samples
overlap = R - L; % Overlap = 50% of window length
[s f t] = spectrogram(bv,window,overlap,N,44100,'yaxis');
figure(1), clf
imagesc(t,f(370:745),log10(s)); % 250~500kHz mark
colormap(jet)
axis xy
xlabel('time')
ylabel('frequency')
title('SPECTROGRAM, R = 30')
s2 = s(370:745,:); % 250 ~ 500kHz mark
[X,Y] = meshgrid(t,f(370:745)); % Meshgrid 생성
Z = abs(s2);
mesh(X,Y,Z); % Mesh 그래프 표시
figure;
contour(X,Y,Z) % Contour 그래프 표시
my error is segment length is more than long input signal
but i don't no what is wrong about this line
[s f t] = spectrogram(bv,window,overlap,N,44100,'yaxis');-this line make error

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 5 Jun 2020
If bv has a size of 110x1 or 1x110, then you're trying to calculate a spectrogram of a 110-long time-series using a 10000-sample long window. It seems likely that you want to calculate the spectrogram of the intensities you got fom the audioread-call. Perhaps this is what you want:
[s f t] = spectrogram(y,window,overlap,N,44100);
If that's not right you have to call spectrogram with a time-series that is at least longer than your window.
HTH

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!