⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo7.m

📁 这是一个 York大学开发的FDTD代码。很好用的工具
💻 M
字号:
% 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)];%%disp(' Window x');%Full Gaussian%w=exp(-((tx-Tp/2)./(0.2*Tp)).^2);%Half Gaussian%w=exp(-(tx./(1*Tp)).^2);%Integrated Gaussian end%w0=exp(-((tx-Tp)./(0.1*Tp)).^2);%plot(tx,w0);%w=1 - psum(w0)/sum(w0);%Integrated Gaussian both ends%kw=0.1;%w1=exp(-((tx-kw)./(kw*Tp)).^2);%w0=exp(-((tx-kw)./(kw*Tp)).^2) - exp(-((tx-Tp)./(kw*Tp)).^2);%plot(tx,w0);%w=psum(w0)/sum(w1);%Raised cosine at both endskw=0.2w=[(1-cos(0:pi/(kw*(N)):pi))*0.5,ones(1,N*(1-2*kw)-2),0.5*(1+cos(0:pi/(kw*(N)):pi)),zeros(1,NX-N)];xlabel('Time')
title('The window function')plot(tx,w);
input('Any key to continue')x=x.*w*N/sum(w);%title('Cosine waves windowed')xlabel('Time')plot(tx,x)title('Extended time series with window')
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);title('Discrete Fourier Transform Spectra (Extending the time series)')xlabel('Frequency/fs')ylabel('abs(X)')semilogy(fx/fs,abs(XD),'-',f0/fs,ones(1,size(f0,2)),'+')

⌨️ 快捷键说明

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