TPORC
Newbie level 1

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?
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
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?