I am plotting a spectrogram using STFT algorithm generated by me everything works fine but my results are not what i expected please help me where I am wrong.
clear all
close all
clc
Fs = 2*max(100,300);
t = 0:1/Fs:1-1/Fs;
t1 = t(end);
x = chirp(t,300,t1,100,'linear');
w = rectwin(10)';
nw= length(w);
X = fft(x);
Total = [];
y = length(x) - nw;
for tau = 0: y
S = 0;
if tau == 0 %1st window
S = X(1:nw);
else %THE remaining windows generated from here
for k = 0:nw-1
for n = 0:nw-1
S= (exp(2*pi*1j*k/nw).*(X(tau : tau + nw-1) - x(tau)+...
x(nw+tau).*exp(-2*pi*1j*n/nw)));
end
end
end
W= S(1:end/2);
Total = [Total; W];
end
%plotting
T = 1:length(x)/2;
imagesc(T,1:Fs/2,20*log10(abs(Total).^2))
axis xy; axis tight; colormap(jet);
xlabel('Time in sec');
ylabel('Frequency (Hz)');

댓글 수: 9

Walter Roberson
Walter Roberson 2012년 2월 2일
The easiest solution would be to change what you are expecting.
We do not know what you are expecting, so there are no code changes we can suggest.
raj
raj 2012년 2월 2일
i am expecting a spectrogram for a chirp signal using short time fourier transform...
raj
raj 2012년 2월 2일
the chirp should start from 300 Hz and end at 100 Hz
Walter Roberson
Walter Roberson 2012년 2월 2일
A chirp that _starts_ at 300 Hz, and _ends_ at 100 Hz? Not 300 to 1000 ? Not 100 to 300 ?
raj
raj 2012년 2월 2일
I mean to say at t = 0 it starts at 300 Hz and at t(end) it is at 100 Hz
raj
raj 2012년 2월 2일
I didnt understand your question..
Image Analyst
Image Analyst 2012년 2월 2일
Chirps increase in frequency as time goes along - the wavelength decreases. See figures in http://en.wikipedia.org/wiki/Chirp_signal .
Walter Roberson
Walter Roberson 2012년 2월 2일
Looking at that page, they say that down-chirps exist, and it appears that k (rate of increase in frequency) could be negative.
raj
raj 2012년 2월 2일
My problem is not with chirp signal consider any signal but I am not getting the spectrogram expected please try with a signal of ur own

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

질문:

raj
2012년 2월 2일

편집:

Jon
2013년 9월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by