ex11_5.m

来自「Programs for the book Advanced Engineeri」· M 代码 · 共 23 行

M
23
字号
% EX11_5.M Compute the spectrum of a signal saved
%   in file CLEX115.MAT. (Created by CLEX115DT.M) The data are:
%   N   samples of the |FFT| are plotted
%   Ts   sampling interval in seconds
%   t   time points
%   ft  function f(t)
% Calls clfftf to compute DFT
load clex95.mat                    % Load N,Ts,t,ft
fs=1/(N*Ts);                       % Frequency spacing	
fhertz=fs*linspace(-N/2,N/2-1,N);  % Create frequency axis
[FT,FTmag,FTarg]=clfftf(ft,N,Ts);  % Compute DFT
% Plot f(t) and DFT 
subplot(2,1,1), plot(t,ft)         % Time function
title('Signal')
xlabel('Time in seconds'), ylabel('f(t)')
subplot(2,1,2),plot(fhertz, FTmag) % Spectrum
xlabel('Frequency in hertz')
ylabel('Spectrum')
%
% Modify the script to use other data files. The M-file
%  that created the data file is CLEX95DT.M

⌨️ 快捷键说明

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