clear all;
N=2000;
fs=2000;
n=0:N;
t=n*1/2000;
x1=cos(2*pi*200*t).*(t>=0 & t<=0.8);
x2=cos(2*pi*50*t).*(t>=0.2 & t<=1);
x=x1+x2;
figure(1);
plot(t,x);
title('原始信号');
xlabel('时间 t');
ylabel('幅值 A');
grid on;
figure(2);
subplot(311);
[tfr,t,f]=tfrwv(x',1:N,N);
contour(t/fs,f(1:length(f)/2)*fs,abs(tfr(1:length(f)/2,:)));
title('Wigner-Ville分布时频图');
xlabel('时间 t');
ylabel('频率 f');
grid on;
subplot(312);
[tfr,t,f]=tfrpwv(x',1:N,N);
contour(t/fs,f(1:length(f)/2)*fs,abs(tfr(1:length(f)/2,:)));
title('伪Wigner-Ville分布时频图');
xlabel('时间 t');
ylabel('频率 f');
grid on;
subplot(313);
[tfr,t,f]=tfrspwv(x',1:N,N);
contour(t/fs,f(1:length(f)/2)*fs,abs(tfr(1:length(f)/2,:)));
title('平滑伪Wigner-Ville分布时频图');
xlabel('时间 t');
ylabel('频率 f');
grid on;
figure(3);
mesh(t/fs,f(1:length(f)/2)*fs,abs(tfr(1:length(f)/2,:)));
title('三维时频图');
xlabel('时间 t');
ylabel('频率 f');
zlabel('幅值 A');
评论2