why the fft results of these functions are not what I expect?

2 visualizaciones (últimos 30 días)
2NOR_Kh
2NOR_Kh el 8 de Dic. de 2022
Editada: 2NOR_Kh el 9 de Dic. de 2022
I have three functions; a sinusoid, square and sawtooth. The fft of sine is what we expect in fourier domain. But I expect to see a sinc function for the square. But why its not what I expect?
close all;
clear all;
fs=1e5;
a=-0.01;
b=0.01;
t = a:1/fs:b;
x = sin(1000*2*pi*t);
y = sawtooth(500*2*pi*t);
z = square(2000*2*pi*t);
N=length(x);
figure, subplot(1,3,1), plot(t,x);xlim([a/10 b/10])
subplot(1,3,2), plot(t,y);xlim([a/10 b/10])
subplot(1,3,3), plot(t,z);xlim([a/10 b/10])
A = 2*fftshift(abs(fft(x))/N);
b = 2*fftshift(abs(fft(y)))/N;
c = 2*fftshift(abs(fft(z)))/N;
if mod(N,2) == 0 % N is even
f = ( (-N/2) : ((N-2)/2) )/N*fs;
else % N is odd
f = ( (-(N-1)/2) : ((N-1)/2) )/N*fs;
end
figure
plot(f, c); xlim([-fs fs])
figure
plot(f, b);xlim([-fs fs])
figure
plot(f, A);xlim([-fs fs])
  6 comentarios
Paul
Paul el 9 de Dic. de 2022
The energy of a signal is not the area under the curve. link to reference
2NOR_Kh
2NOR_Kh el 9 de Dic. de 2022
Editada: 2NOR_Kh el 9 de Dic. de 2022
thanks alot. It was a great help.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by