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

조회 수: 2 (최근 30일)
2NOR_Kh
2NOR_Kh 2022년 12월 8일
편집: 2NOR_Kh 2022년 12월 9일
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
Paul
Paul 2022년 12월 9일
The energy of a signal is not the area under the curve. link to reference
2NOR_Kh
2NOR_Kh 2022년 12월 9일
편집: 2NOR_Kh 2022년 12월 9일
thanks alot. It was a great help.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by