📄 cftbyfft.m
字号:
function [AW,f]=cftbyfft(wt,t)
%cftbyfft.m
%根据参考书修改后的程序,其正确性已经过验证,无论幅度还是频率都是正确的
%本程序采用FFT计算连续时间Fourier变换。输出幅频谱数据对(f,AW)
%
%
N=length(t); %信号的采样点数,也就是FFT的点数N
T=t(length(t))-t(1); %信号的时间宽度T
dt=T/N; %采样间隔dt
W0=fft(wt,N);
df=1/T; %频率分辨率df
n=floor(-(N-1)/2:(N-1)/2);%B = floor(A) rounds the elements of A to the nearest integers less than or equal to A.
%For complex A, the imaginary and real parts are rounded independently.
W0=fftshift(W0);
f=n*df;
%AW=abs(W0)/N; %wt为周期信号时的幅度谱
AW=abs(W0)*dt; %wt为非周期信号时的幅度谱
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -