Error in FFT calculation
显示 更早的评论
Why the FFT value shows higher value in the cut signal when compared to whole signal, it should be opposite right?
close all
clear all
clc
load("allSignals.mat");
Fs = 50e6; % Sampling frequency
T = 1/Fs; % Sampling period
L = 7500; % change as required
t = (0:L-1)*T; % Time vector
X = allSignals(1,:);
plot(t,X)
title("Signal ")
xlabel("t ")
ylabel("X(t)")
% fft
Y = fft(X);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title("Single-Sided Amplitude Spectrum of X(t)")
xlabel("f (Hz)")
ylabel("|P1(f)|")
figure ; % after cut
X1 = allSignals(1,500:1100);
L1 = length(X1);
Y1 = fft(X1);
P21 = abs(Y1/L1);
P11 = P21(1:L1/2+1);
P11(2:end-1) = 2*P11(2:end-1);
f1 = Fs*(0:(L1/2))/L1;
plot(f1,P11)
title("Single-Sided Amplitude Spectrum of X(t)")
xlabel("f (Hz)")
ylabel("|P1(f)|")
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Event Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


