Zero Pad My FFT Signal and Window
Show older comments
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')
Accepted Answer
More Answers (1)
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 Comments
David Harra
on 4 Apr 2022
Matt J
on 4 Apr 2022
If you are already over-sampled, you will not see a change. There's no way to know more without attaching Data for us.
David Harra
on 4 Apr 2022
Matt J
on 4 Apr 2022
Could you just attach a .mat file containing Data. That's all we need to run your code.
Categories
Find more on Spectral Measurements 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!