Zero Pad My FFT Signal and Window
20 次查看(过去 30 天)
显示 更早的评论
Hi Everyone I want to know how I can zero pad my FFT signal to make it longer so that I can get better frequency resolution. In my line of code below that shows (FTSignal = fft(Signal-meanSignal, 15000000)/N), I thought this number would define the zero padding, but I am not confident it is doing what I believe it to do.
I have also applied my hanning window in my FFT domain, I have been told it is better to do this in the time domain before FFT, but based on my code below I am not too sure what to do. I did try Data=hann(length(Data)) but this is incorrect.
Any pointers for the zero padding and windowing would be appreciated
%% Read in Data
FName = 'Tit_10MHz_110F.flxhst';
MyData = read_history(FName);
Time = MyData.TimeRecB.Time;
Data= MyData.DataRecB(1).Data;
%% Take the signal and normalize
Data = Data./max(abs(Data)); % This is the normalized signal
% Data=hann(length(Data))
%% Plot the time domain signal
figure(1)
plot(Time*1e6, Data);
grid
xlabel('Time \mus')
ylabel('Amplitude')
%% Set up the FFT Parameteres
Signal= Data;
Ts=Time(2)- Time(1); %Time Step
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz) half of the sampling rate of a discrete signal processing system
N = length(Signal); % Lengh of signal
meanSignal = mean(Signal); % ‘Signal’ Mean
FTSignal = fft(Signal-meanSignal, 15000000)/N; % Normalised Fourier Transform Of Baseline-Corrected &Signale& zero Padded
FTSignal = fft((Signal(:)-meanSignal) .* hann(length(Signal)) ) / N; %Apply hanning window to the data
%% Set up FFT Verctors
Fv = linspace(0, 1, fix(numel(FTSignal)/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
%% Plot FFT
figure(2)
plot(Fv/1e6, abs(FTSignal(Iv))*2)
xlim([0 20])
grid
xlabel('Frequency(MHz)')
ylabel('Amplitude')
0 个评论
采纳的回答
Star Strider
2022-4-4
编辑:Star Strider
2022-4-4
I recognise my code!
I see nothing wrong with that (although I do not understand the two fft calls), however I would change it to:
NFFT = 2^nextpow2(15000000);
FTSignal = fft(Signal-meanSignal, NFFT)/N; % Normalised Fourier Transform Of Baseline-Corrected &Signale& zero Padded
for efficiency.
The ‘Fv’ assignment is correct. (It is taken from the R2015b documentation.)
Similarly, this would likely work:
FTSignal = fft((Signal(:)-meanSignal, NFFT) .* hann(length(Signal)) ) / N; %Apply hanning window to the data
although it wouold be necessary to experiment with it in the event that:
hann(NFFT)
produces a better result.
EDIT —
I cannot import the data:
Uz = unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/952214/Matlab.zip')
T1 = readtable(Uz{3})
.
0 个评论
更多回答(1 个)
Matt J
2022-4-4
编辑:Matt J
2022-4-4
The zero-padding is fine. The way you set up your frequency axis, I'm a little unsure about.
N=numel(FTSignal);
NormalizedAxis= (0:N-1)-ceil((N-1)/2);
Fv=NormalizedAxis/N/Ts;
plot(Fv,fftshift(abs(FTSignal)))
4 个评论
Matt J
2022-4-4
Could you just attach a .mat file containing Data. That's all we need to run your code.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!