demo6.m

来自「这是一个 York大学开发的FDTD代码。很好用的工具」· M 代码 · 共 31 行

M
31
字号
% uses setup from demo0disp('Constant cosine-waves - extended window with zero padding')disp('Generate time and frequency steps')Ts=Tp/(N)fs=1/Tsf=linspace(0,fs*(N-1)/N,N);fx=linspace(0,fs*(NX-1)/NX,NX);disp('Generate time steps for one period (t)');t=linspace(0,Tp*(N-1)/N,N);tx=linspace(0,NX/N*Tp*(NX-1)/NX,NX);disp('Generate time sequence (x) and plot it against time (t)')x=ones(1,size(f0,2))*(cos(2*pi*f0'*t));x=[x,zeros(1,NX-N)];plot(tx,x)
title('Cosine waves extended (padded) with zeros')xlabel('Time')input('Any key to continue')disp('Generate DFT (X) of time series (x) and Compare with Fourier transform of continous data');XD=2*Ts*fft(x);XD(1)=0.5*XD(1);semilogy(fx/fs,abs(XD),'-',f0/fs,ones(1,size(f0,2)),'+')
title('Discrete Fourier Transform Spectra (Extending the time series)')xlabel('Frequency/fs')ylabel('abs(X)')

⌨️ 快捷键说明

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