马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
本帖最后由 牛小贱 于 2014-7-4 23:42 编辑
- function [WVD] = 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([iIndex-1,SigLen-iIndex,round(FreqBins/2)-1]);
- 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',[20 100 400 300]);
- set(gcf,'Color','w');
- mesh(t,f,abs(WVD));
- colormap('Jet');
- colorbar;
- axis([min(t) max(t) min(f) max(f)]);
- ylabel('Frequency / Hz');
- xlabel('Time / Sec');
- title('Wigner-Ville distribution');
复制代码
|