Amplitude spectrum concentrated around the wrong frequency
1 view (last 30 days)
Show older comments
I have an ultrasonic signal obtained by scanning a specimen using a 7.5 MHz probe (which is close to the resonance frequency of the material) with a spherical focus of 1.5 inches. I am calculating the fft of the signal, truncating to half the length, taking the magnitude and then I finally define the frequency step as follows:
Spectrum = fft(real(Signal));
Spectrum=Spectrum(1:length(Spectrum)/2+1);
AmplitudeSpectrum = abs(Spectrum);
fft_pts = 2^nextpow2(length(TimeInMicroSec)) ;
FreqIncInMHz = 1.0 / (TimeIncrementInMicroSec*fft_pts) ;
FreqInMHz = zeros(size(Spectrum));
for i = 1:length(FreqInMHz)
FreqInMHz(i) = double(i-1)*FreqIncInMHz;
end
I then plot the amplitude against the frequency (as shown in the figure below) but instead of getting a distribution concentrated around the centre frequency of the transducer, my results are off by a factor of 2 approximately. I am not sure what is causing this.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/454378/image.png)
1 Comment
Star Strider
on 8 Dec 2020
I strongly suspect that you are not calculating the frequency vector correctly. It should extend from 0 Hz (D-C) to the Nyquist frequency (half the sampling frequency). The ‘FreqIncInMHz’ calculation is a complete mystery.
Answers (1)
Mathieu NOE
on 8 Dec 2020
hello
FYI, this is my fft code for doing averaging fft (works also for no averaging) :
function [freq_vector,fft_spectrum] = myfft_peak(signal, Fs, nfft, Overlap)
%FFT peak spectrum of signal (example sinus amplitude 1 = 0 dB after fft).
% signal - input signal,
% Fs - Sampling frequency (Hz).
% nfft - FFT window size
% Overlap - buffer overlap % (between 0 and 0.95)
samples = length(signal);
% fill signal with zeros if its length is lower than nfft
if samples<nfft
s_tmp = zeros(nfft,1);
s_tmp((1:samples)) = signal;
signal = s_tmp;
end
% window : hanning
window = hanning(nfft);
window = window(:);
% compute fft with overlap
offset = fix((1-Overlap)*nfft);
spectnum = 1+ fix((samples-nfft)/offset); % Number of windows
% % for info is equivalent to :
% noverlap = Overlap*nfft;
% spectnum = fix((samples-noverlap)/(nfft-noverlap)); % Number of windows
% main loop
fft_spectrum = 0;
for i=1:spectnum
start = (i-1)*offset;
sw = signal((1+start):(start+nfft)).*window;
fft_spectrum = fft_spectrum + (abs(fft(sw))*4/nfft); % X=fft(x.*hanning(N))*4/N; % hanning only
end
fft_spectrum = fft_spectrum/spectnum; % to do linear averaging scaling
% one sidded fft spectrum % Select first half
if rem(nfft,2) % nfft odd
select = (1:(nfft+1)/2)';
else
select = (1:nfft/2+1)';
end
fft_spectrum = fft_spectrum(select);
freq_vector = (select - 1)*Fs/nfft;
end
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!