1.本书包含的实例所使用的源程序清单

源代码在线查看: 6-2.m

软件大小: 32 K
上传用户: liu2000dz
关键词: 源程序 清单
下载地址: 免注册下载 普通下载 VIP

相关代码

				%例程6-2  计算非平稳随机信号的STFT时频谱
				% e.g.6-2.m for example6-2;
				 
				clear;
				N=500;      %length of the signal x.
				t=0:N-1;
				x=zeros(size(t));
				%Generate two sine signal with different frequencies.
				x(50:150)=cos(pi*(t(50:150)-50)/10);   
				x(250:350)=cos(pi*(t(250:350)-250)/20);
				subplot(221);
				plot(x);
				axis([ 0 500 -1 1]);
				grid;
				X=fft(x);
				X=fftshift(X);         %Shift zero-frequency component to center of spectrum
				subplot(222);
				plot(abs(X));
				axis([0 500 0 60 ]);
				grid;
				Nw=20;          %window length
				L=Nw/2;
				Ts=round((N-Nw)/L)+1;     
				nfft=128;
				TF=zeros(Ts,nfft);
				for i=1:Ts
				    xw=x((i-1)*L+1:i*L+L);
				    temp=fft(xw,nfft);
				    temp=fftshift(temp);
				    TF(i,:)=temp;
				end
				subplot(223);
				mesh(abs(TF));
				subplot(224);
				contour(abs(TF));
				axis equal tight         % set the axes aspect ratio
				grid;
							

相关资源