mm2201.m

来自「《精通matlab7》“mastering matlab 7”的代码。」· M 代码 · 共 18 行

M
18
字号
% mm2201.m

N = 128;  % choose a power of 2 for speedt = linspace(0,3,N);  % time points for function evaluationf = 2*exp(-3*t);  % evaluate the function and minimize aliasing: f(3) ~ 0Ts = t(2) - t(1);  % the sampling periodWs = 2*pi/Ts;  % the sampling frequency in rad/secF = fft(f); % compute the fftFc=fftshift(F)*Ts;
W=Ws*(-N/2:(N/2)-1)/N;

Fa = 2./(3+j*W); % evaluate analytical Fourier transform
plot(W,abs(Fa),W,abs(Fc),'.') % generate plot, 'o' mark fft resultsxlabel('Frequency, Rad/s')ylabel('|F(\omega)|')title('Figure 22.1: Fourier Transform Approximation')

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?