问题
I run by using the function tfrwv.m in Time-Frequency Toolbox
[B,T,F] = tfrwv(data, 1:length(data), length(data), 1);
B(1:130, :) = 0; % remove the duplicate part of the distribution
imagesc(T, F, abs(B));
colormap(hot);
xlabel('t [s]');
ylabel('f [Hz]');
I get
The frequency should be within [0,180] Hz and time [0,2.5s].
How can you scale time and frequency to the real values?
The manuals says
%TFRWV Wigner-Ville time-frequency distribution.
% [TFR,T,F]=TFRWV(X,T,N,TRACE) computes the Wigner-Ville distribution
% of a discrete-time signal X,
% or the cross Wigner-Ville representation between two signals.
%
% X : signal if auto-WV, or [X1,X2] if cross-WV.
% T : time instant(s) (default : 1:length(X)).
% N : number of frequency bins (default : length(X)).
% TRACE : if nonzero, the progression of the algorithm is shown
% (default : 0).
% TFR : time-frequency representation. When called without
% output arguments, TFRWV runs TFRQVIEW.
% F : vector of normalized frequencies.
%
% Example :
% sig=fmlin(128,0.1,0.4); tfrwv(sig);
%
and I Run
[B,T,F] = tfrwv(data, 1:length(data), length(data), hamming(length(data)/10), hamming(length(data)/4));
and I get
Error using tfrwv
Too many input arguments.
Error in flow_wv (line 8)
[B,T,F] = tfrwv(data, 1:length(data), length(data),
hamming(length(data)/10), hamming(length(data)/4));
I think the problem here is initialising the windows for time and frequency. I am trying to manipulate the both axis, by editing the values of the parameters.
A corresponding Spectrogram of the same data but with axis of right labels is, done by Matlab's default spectrogram function, discussion here:
回答1:
I think tfrwv
is equivalent to spectrogram
if you use the following command.
Time-interval is t = 1/360
.
Choose fs = 360.5
.
imagesc(T*t, F*fs, abs(B));
There are more peaks in tfrwv
probably because the window size and overlap are different from what you used in spectrogram
.
The result
回答2:
There is no concept of overlap in the Wigner-Ville distribution. That only applies to STFT and the Spectrogram which is the square modulus of the STFT.
The results from the 'tfrwv' (and all the TFR calculations in the TFTB) are in normalized frequency units. You can't get the units in frequency and seconds with out supplying a sampling frequency\rate.
This is too many input arguments.
[B,T,F] = tfrwv(data, 1:length(data), length(data), hamming(length(data)/10), hamming(length(data)/4));
There are three output arguments and up to four input arguments, so yeah giving it five is going to throw an error. Also, the fourth input argument is a boolean for turning on tracing which just prints some progress info to the Matlab command window as it calculates.
Just for a reality check make your tfrwv
call with no output arguments (i.e. >> tfrwv(blah, blah);
) this will cause it to call tfrqview
which is a menu driven plotting tool. On of the options in the menu is to change the sampling frequency (enter you sampling frequency in Hertz at the Matlab command prompt) and it will update the figure to have actual frequencies on the y-axis and times on the x-axis. Otherwise the default is normalized frequency and the y-axis is actually time in units of samples.
To do this by-hand, you will need to use a 3D "plot", one where you can use the sampling rate to convert the T
and F
vectors to be true time and true frequency instead of samples and normalized frequency (normalized frequency being [0 0.5]). Then the TFR
is used to apply a color to the z-axis, i.e. >>imagesc(T.*1/Fs, F.*Fs, TFR);
The TFTB is an awesome toolbox with the best documentation I've ever seen from an open-source third party Matlab toolbox. Dig around in it for the "refguide.pdf" and "tutorial.pdf".
来源:https://stackoverflow.com/questions/20750660/to-scale-values-from-wigner-ville-distribution-to-real-range-in-matlab