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

1 Ansicht (letzte 30 Tage)
2NOR_Kh
2NOR_Kh am 8 Dez. 2022
Bearbeitet: 2NOR_Kh am 9 Dez. 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 Kommentare
Paul
Paul am 9 Dez. 2022
The energy of a signal is not the area under the curve. link to reference
2NOR_Kh
2NOR_Kh am 9 Dez. 2022
Bearbeitet: 2NOR_Kh am 9 Dez. 2022
thanks alot. It was a great help.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

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

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by