フィルターのクリア

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 Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by