These should work in MATLAB or Octave.
A simple pseudo Wigner-Ville Distribution.
An inverse FFT which always returns real values.
An alternate to the MATLAB hilbert function.
A simple pseudo Wigner-Ville Distribution.
Code:
[FONT=courier new]function [ WD, f, t ] = wvd( x, Fs )[/FONT]
[FONT=courier new]%WVD compute discrete wigner-ville distribution[/FONT]
[FONT=courier new]% x - analytic signal[/FONT]
[FONT=courier new]% Fs - sampling frequency[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new][N, xcol] = size(x);[/FONT]
[FONT=courier new]if N<xcol[/FONT]
[FONT=courier new] x = x.';[/FONT]
[FONT=courier new] N = xcol;[/FONT]
[FONT=courier new]end[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new]WD = zeros(N,N);[/FONT]
[FONT=courier new]t = (1:N)/Fs;[/FONT]
[FONT=courier new]f = (1:N)*Fs/(2*N);[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new]for ti = 1:N[/FONT]
[FONT=courier new] taumax = min([ti-1,N-ti,round(N/2)-1]);[/FONT]
[FONT=courier new] tau = -taumax:taumax;[/FONT]
[FONT=courier new] WD(tau-tau(1)+1,ti) = x(ti+tau).*conj(x(ti-tau));[/FONT]
[FONT=courier new]end[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new]WD = 2.*fft(WD);[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new]end[/FONT]
An inverse FFT which always returns real values.
Code:
function [ x ] = idft_real( X )
%Return inverse FFT always real
Y = real(X) + imag(X);
y = ifft(Y);
x = (real(y)+imag(y));
end
An alternate to the MATLAB hilbert function.
Code:
function [ z ] = analytic( s )
%ANALYTIC Compute the analytic function
N = length(s);
S = fft(s,2*N);
S(2:N) = S(2:N).*2;
S(N+2:2*N)=0;
z = ifft(S);
z(N+1:2*N) = 0;
end