FFT when rescaling data
显示 更早的评论
Hi everyone
I have been trying to use an FFT on my imported data. My Time step from my data wasn't equidistant so I tried to use the interp1 function as seen in the code below and it seems to give me a plot which seems reasonable, so I think the code is correct. My time and frequency domain can be seed side by side just below.
My issue is when I try to rescale my data such that the amplitude is rescaled from 0 to 1. You can see the time domain signal is scaled but the FFT looks very off and I have no idea why. Its making me not feel confident about my origanl attempt of the FFT or I am perhaps not accounting for something when rescaling the data. Also below you can see my recaled images showing how different the FFT has turned out
Any help would be great. Thanks :)


FName = 'Tit_10MHz_110F.flxhst';
MyData = read_history(FName);
Time = MyData.TimeRecB.Time;
Data= MyData.DataRecB(1).Data;
%%
%Start signal from the front wall
select= find(Time>=2.7e-6 & Time<=7e-6);
Time= Time(select);
Data= Data(select);
% Data=rescale(Data);
%Plot Data
figure(01)
plot(Time,Data)
xlabel('Time (s)')
xlim([2.7e-6 7e-6])
ylabel('Amplitude')
title('Features 110 Full A-scan')
%FFT of full signal
dt=Time(2)-Time(1); %Time step
xq=Time(1):dt:Time(end); % Time step is not equidistant so need to create time array and inerpolate the data ?
interpolated_signal=interp1(Time, Data, xq).' ;
fft_points = 2 ^ nextpow2(size(interpolated_signal, 1));
time_step=xq(2)- xq(1); % New Time step
frequency_spectrum = fft(interpolated_signal, fft_points);
frequency_spectrum = frequency_spectrum(1:end / 2, :);
frequency_step = 1 / (fft_points * time_step);
frequency = ([1 : fft_points / 2] - 1) * frequency_step;
figure(02)
plot(frequency/1e6, abs(frequency_spectrum));
xlabel('Frequency (MHz)')
xlim([0 20])
ylabel('Amplitude')
title('Features 110 FFT Full Signal')
3 个评论
Walter Roberson
2022-3-25
Is there a reason you did not use nufft() for your irregular timestep ?
David Harra
2022-3-25
Walter Roberson
2022-3-25
frequencey_spectrum = nufft(Data, Time, fft_points);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!