why my fft doesnot give the correct answer??
Ältere Kommentare anzeigen
i have the signal which consist of fundamental frequency and some harmonics, while doing fft i m not getting correct answer like i get in fftanalysis using powergui tool in simulink. the code is as follows. please help me out.
signal= xlsread('Isa.xlsx');
X=signal(:,1);
fs=1e6;
fnyquist=fs/2;
t=[0:1/fs:1];
N=length(t);
X_mag=abs(fft(X));
bin_vals= [0 :(N-1)];
fax_Hz=bin_vals*fs/N;
N_2=ceil(N/2);
subplot(2,1,1)
% abs(fft(X))
plot(fax_Hz,X_mag)
xlabel('Frequency (Hz)')
ylabel('Magnitude');
Antworten (1)
Sulaymon Eshkabilov
am 19 Jul. 2019
Hi,
There are several unclear points, i.e. your time signal and sampling frequency fs match with your signal from sla.xls, etc. They have to match. In other words, they need to have the same values.
Here is a simple example that you can adjust with your data (sla.xlsx), such as fs, t, N:
fs=1e3; % Sampling frequency
tend = 5; % End value of time signal
t=0:1/fs:tend;
L = numel(t); % Length of a signal. Note that t has to match with your data from your xlsx file
signal= sin(13*2*pi*t)+cos(113*2*pi*t)+.01*randn(size(t)); % signal=xlsread('sla.xlsx');
N = 2048; % Block size can be: 4096, 8192, ...
Y1 = abs(fft(signal, N))/L;
f=fs/2*linspace(0, 1, N/2+1);
figure
plot(f, 2*Y1(1:N/2+1), 'r-'), grid on, legend('Y1', 'location', 'SouthEast')
title 'FFT of signal(t)'
shg
Good luck.
Kategorien
Mehr zu Fourier Analysis and Filtering finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!