Plot Wavelet FFT in Hz
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi! I'm trying to do fft of wavelet function. But I'm confused: how to define x-axis f in Hz? Here is my code:
scales=1:100;
wname='db20';
N=10;
[phi, psi, tgrid] = wavefun (wname, N);
f=???
figure;
hold on
plot(f,abs(fft(phi)));
plot(f,abs(fft(psi)));
before, in my practice, i used:
f=0:Fs/(N-1):Fs;
What should I do now?
0 Commenti
Risposte (2)
Robert U
il 8 Ago 2017
Modificato: Robert U
il 8 Ago 2017
Hello Alexander,
if you want to display wavelet analysis in terms of frequency one common way is to use the center frequency of the used wavelet.
Using a web search engine you could have searched for "wavelet equivalent frequency" which is providing several useful explanations as: https://de.mathworks.com/videos/understanding-wavelets-part-1-what-are-wavelets-121279.html
Kind regards,
Robert
1 Commento
Alexander Voznesensky
il 8 Ago 2017
Modificato: Alexander Voznesensky
il 8 Ago 2017
Robert U
il 9 Ago 2017
Hi Alexander,
if you want to plot the Fourier spectrum of the wavelet you can apply the usual fft algorithm (described here: https://de.mathworks.com/help/matlab/math/basic-spectral-analysis.html ).
%%Create wavelet
wname='db20';
N=12;
[phi, psi, tgrid] = wavefun (wname, N);
%%Calculate FFT of wavelet output
SampleFrq = 2^N; % calculate sample frequency of signals
SigL = length(psi); % phi & psi have same length
NFFT = 2^nextpow2(SigL); % standard fft calculation
SigMagPsi = fft(psi,NFFT)/SigL;
SigMagPsi = 2*abs(SigMagPsi(1:NFFT/2+1));
SigMagPhi = fft(phi,NFFT)/SigL;
SigMagPhi = 2*abs(SigMagPhi(1:NFFT/2+1));
f = SampleFrq / 2 * linspace(0,1,NFFT/2+1);
%%Plot Figure
figure;
hold on
plot(f,SigMagPhi);
plot(f,SigMagPsi);
ah = gca;
ah.XScale = 'log';
ah.YLabel.String = 'Magnitude';
ah.XLabel.String = 'Frequency [Hz]';
legend(['Phi';'Psi'])
figure;
centfrq(wname,N,'plot')
2 Commenti
Alexander Voznesensky
il 9 Ago 2017
Modificato: Alexander Voznesensky
il 9 Ago 2017
Robert U
il 10 Ago 2017
Hello Alexander:
The basic idea is to understand the generated wavelet as a time-dependent signal that is sampled with a certain (fixed) sampling frequency even though it could be a function depending on any physical (scalar) value (e.g. distance).
Sampling frequency is the step size of your points grid XVAL (tgrid). Assuming that they are equidistantly distributed you can check the equivalent sampling frequency by
Fs = 1 / mean( diff( tgrid ));
You will see that the sampling frequency increases with the number of iterations. You can calculate your sampling frequency either with the formula above or you convince yourself that the scaling is according to
Fs = 2^N;
This feature was documented on earlier versions ( http://radio.feld.cvut.cz/matlab/toolbox/wavelet/wavefun.html ) and is still for wavefun2 ( https://de.mathworks.com/help/wavelet/ref/wavefun2.html).
[PHI,PSI,XVAL] = wavefun('wname',ITER) returns the scaling and wavelet functions on the 2^ITER points grid XVAL.
Kind regards,
Robert
Vedere anche
Categorie
Scopri di più su Continuous Wavelet Transforms in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!