FFT returns a different amplitude value, why?

4 Ansichten (letzte 30 Tage)
André Luiz Regis Monteiro
Dear Colleagues,
I am working in this code (attached):
t = 0:0.05:4*pi; x=2+1.5*cos((2*pi/360)*60*t+(2*p)i/360)*90) N1=length(t) n1=log2(N1) n1=ceil(n1) vet = 2^n1 %multiple of 2^n;
b = N1+1; while b~=vet+1 t(b)= (t(b-1)-t(b-2))+t(b-1) %complementing the time vector to the lentgh vet; x(b)= 0 %comlementing the vector x with zeros until lenght vet; b=b+1 end
sample_rate=1/(abs(t(2)-t(1))) f=sample_rate*((0:vet/2))/vet %vector frequency associated; n=length(f) X=fft(x) fftX=X*1/(vet) abs_fftX=abs(fftX(1:n)) figure(1) stem(f,abs_fftX)
When I compute fft and plot (stem) the result, appears 1.94 in the graphic origin (phase is zero) instead of 2. It needs to be 2 (phase is zero), because it is a DC signal from x= 2 +1.5*cos((2*pi/360)*60*t+(2*p)i/360)*90). So, maybe in the others frequencies could be wrong too. Could somebody teach me how to fix it? Thanks a lot.

Antworten (0)

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by