필터 지우기
필터 지우기

I'm trying to create plots of Fourier Synthesis and FFT Spectrum of a square wave using harmonics, but I keep getting a vector length error for the FFT spectrum.

조회 수: 3 (최근 30일)
N = 5;
f0 = 5;
tw = 1;
k = [1:2:N];
ak = 2./(pi*k);
T0 = 1/f0;
fs = 20*2*N*f0;
ts = 1/fs;
y = 0.5;
for m=1:length(k)
t=(0:ts:tw);
x = ak(m).*cos(2*pi*f0*k(m)*t-pi/2);
y = y+x;
h = plot(t,y);
xlabel('Time (s)')
end
fa = 0:fs/N:fs-fs/N;
f = fft(y)/N;
F = abs(f);
figure, plot(fa,f)

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by