Borrar filtros
Borrar filtros

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 visualizaciones (últimos 30 días)
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)

Respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by