自编程序分享-Wigner-Ville- Distribution
本帖最后由 牛小贱 于 2014-7-4 23:42 编辑function = WignerVille(Sig,SampFreq,FreqBins);
% Sig : 输入信号
% FreqBins : 频率轴划分区间数(默认为512)
%SampFreq : 信号的采样频率
% WVD : 计算结果
if (nargin < 1),
error('At least one input required');
end;
Sig = hilbert(real(Sig)); % 计算信号的解析信号
SigLen = length(Sig); %获取信号的长度
if(nargin < 3),
FreqBins = 512;
end
if(nargin < 2),
SampFreq = 1;
end
FreqBins = 2^nextpow2(FreqBins);
FreqBins = min(FreqBins, SigLen);
WVD = zeros (FreqBins,SigLen);
wait = waitbar(0,'Under calculation, please wait...');
for iIndex = 1:SigLen,
waitbar(iIndex/SigLen,wait);
MTau = min();
tau = -MTau : MTau;
Temp = rem(FreqBins + tau,FreqBins) + 1;
WVD(Temp,iIndex) = Sig(iIndex + tau) .* conj(Sig(iIndex - tau)); %计算x*(t-1/2τ) x(t+1/2τ)
end;
close(wait);
WVD = fft(WVD)/FreqBins;
f = linspace(0,0.5,FreqBins)*SampFreq;
t = (0: SigLen-1)/SampFreq;
set(gcf,'Position',);
set(gcf,'Color','w');
mesh(t,f,abs(WVD));
colormap('Jet');
colorbar;
axis();
ylabel('Frequency / Hz');
xlabel('Time / Sec');
title('Wigner-Ville distribution');
WVD测试程序
本帖最后由 牛小贱 于 2014-7-4 23:44 编辑function TestWVD(),
% SampFreq = 500;
%
% t = 0:1/SampFreq:2;
%
% Sig = sin(50*2*pi*t+50*pi*t.^2);
SampFreq = 100;
t = 0 : 1/SampFreq : 15;
c1 = 2 * pi * 10; % initial frequency of the chirp excitation
c2 = 2 * pi * 2.5; % set the speed of frequency change be 1 Hz/second
c3 = 1 * pi * 1/1.5;
c4 = 2 * pi * -1/40;
Sig = sin(c1 * t + c2 * t.^2 / 2 + c3 * t.^3 /3 + c4 * t.^4 /4); % get the A(t)
%Sig = Sig + sin((1.2*c1 * t + c2 * t.^2 / 2 + c3 * t.^3 /3 + + c4 * t.^4 /4));
figure(1)
plot(t,Sig);
axis tight
xlabel('Time/Sec')
figure(2)
Freq = linspace(0,SampFreq,length(t));
Spec = 2*fft(Sig)/length(t);
plot(Freq(1:end/2),abs(Spec(1:end/2)));
axis tight
xlabel('Frequency /Hz')
figure(3)
pause
WignerVille(Sig, SampFreq,512);
非常感谢!!! 太帅了:handshake 非常感谢!非常感谢!:lol :victory: ,非常感谢啊,学习一下 学习了。。。。
谢谢!
非常谢谢! Thank you for your sharing. 学习一下 非常感谢楼主!!!!! 太厉害了! 恩,学习一下 非常感谢楼主! 很好,楼主很 牛
页:
[1]
2