Plot Wavelet FFT in Hz
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Robert U
2017년 8월 8일
편집: Robert U
2017년 8월 8일
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
Robert U
2017년 8월 9일
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
Robert U
2017년 8월 10일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Continuous Wavelet Transforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!