Need Help about Spectrogram in DSP

Status
Not open for further replies.

TPORC

Newbie level 1
Joined
May 19, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
i've built a function to calculate the spectrogram, but there's always an error.

function [B ,T, F]=MySpectrogram(xx,Nfft,fs,window,Noverlap)
L=64
num_segs=ceil(Nfft/L)
B=zeros(Nfft/2+1,num_segs)
T=[]
F=[]
iseg=0
nstart=0
while (nstart+L-1<Nfft)
nstart=1+iseg*(L-Noverlap)
xsegw=window.*xx(nstart:nstart+L-1);
XX=fft(xsegw,Nfft)
T=[T,iseg*L/fs]

iseg=iseg+1
B,iseg)=XX(1:Nfft/2+1)
end
for n=0:Nfft/2-1
F=[F fs/Nfft*n]

end

Is there anybody can do me a favor to check the matlab code?
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…