我需要使用MATLAB绘制方波的频谱。波在0和-2之间为高(5mV),在0和2之间为低(omv)。我已经获得了傅立叶的seires 对于这个功能,我有该系列的前十个组件。
(5/2)+((10 / pi)* sin((pi * t)/ 2))+((10 /(3 * pi))* sin((3 * pi * t)/ 2 ))+((10 /(5 * pi))* sin((5 * pi * t)/ 2))+((10 /(7 * pi))* sin((7 * pi * t)/ 2 ))+((10 /(9 * pi))* sin((9 * pi * t)/ 2))+((10 /(11 * pi))* sin((11 * pi * t)/ 2 ))+((10 /(13 * pi))* sin((13 * pi * t)/ 2))+((10 /(15 * pi))* sin((15 * pi * t)/ 2 ))+((10 /(17 * pi))* sin((17 * pi * t)/ 2))+((10 /(19 * pi))* sin((19 * pi * t)/ 2 ))
如何使用MATLAB绘制此波的频谱?我尝试过使用FFT,但我真的不知道如何绘制图形。
答案 0 :(得分:0)
直接从fft docs改编,但使用方波作为信号:
Fs = 1000; %// Sampling frequency
freq = 50;
T = 1/Fs; %// Sample time
L = 1000; %// Length of signal
t = (0:L-1)*T; %// Time vector
A = 10; %// Amplitude
y = A*(sin(2*pi*freq*t) > 0); %// Make a square wave
plot(Fs*t,y);
xlabel('time (milliseconds)')
NFFT = 2^nextpow2(L); %// Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
%// Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)') %// probably would be more meaningful if you convert this to radians per second, check out the xtickmark and xtickmarklabel properties of plot
ylabel('|Y(f)|')