📄 ex9_3.m
字号:
% EX9_3.M Compute and plot the DFT of f(t)=exp(-t)% Creates f(t) sampled each Ts seconds for T seconds% Input: N -number of points input% T -Period of signal% t0 =0 -start of time points% Calls clfftf to compute DFTN=input('Number of points N= ') % Sample N pointsT=input('Period of signal T= ')Ts=T/N; % Sampling interval % Form the vector of time points and f(n*Ts)t0=0; % Start of signal ts=(t0:Ts:Ts*(N-1)); % Compute N pointsft=exp(-ts);% Determine the spectrum [Fft,Ffmag,Ffang]=clfftf(ft,N,Ts); % Compute the frequency values in hertz fs=1/(N*Ts); fmax=1/(2*Ts)% fs=1/(N*Ts); % Frequency spacingf=fs*linspace(-N/2,N/2-1,N); % N points in frequency% Plot Fexact and DFT resultw=2*pi*f;Fexact=1./(sqrt(1+w.^2)); % MagnitudeThetaex=-(180/pi)*atan(w); % Angle in degreesclfsubplot(2,1,1),plot(f,Fexact(1:N),'--',f,Ffmag(1:N));title(['FT and DFT of exp(-t), N=',num2str(N), ' T= ',num2str(T),' sec'])xlabel('Frequency in hertz')ylabel('FT and DFT')legend('FT','DFT')subplot(2,1,2),plot(f,Thetaex(1:N),'--',f,Ffang(1:N));xlabel('Frequency in hertz')ylabel('Phase FT and DFT')legend('FT','DFT')%% Try the zoom on command to observe the graphs better.%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -