📄 cft.m
字号:
function [Fw,f]=CFT(ft,dt,t0);
if nargin==1
dt=1;
t0=0;
elseif nargin==2
t0=0;
end
N=length(ft);
T=N*dt;
t=t0+[0:N-1]*dt;
NFFT = 2^nextpow2(N);%计算比N大2的整数次方的数;
k=-NFFT/2:NFFT/2-1;
f=k./T;
W1=dt.*exp(-i*2*pi*t0.*k./T);
F1=fft(ft,NFFT);
Fw=F1.*W1;
Fw=fftshift(Fw);
if nargout==0
subplot(2,2,1);
plot(t,real(ft));
title('信号时域波形实部');
xlabel('Time(s)');
ylabel('f(t)');
grid on;
% Plot single-sided amplitude spectrum.
subplot(2,2,2);
plot(f,abs(Fw));
title('双边功率谱密度幅度');
xlabel('Frequency (Hz)');
ylabel('|F(f)|');
grid on;
subplot(2,2,3);
plot(f,angle(Fw));
title('双边功率谱密度相位');
xlabel('Frequency (Hz)');
ylabel('\phi(f)');
grid on;
subplot(2,2,4);
plot(f,20.*log10(abs(Fw)));
title('双边功率谱密度波特图');
xlabel('Frequency (Hz)');
ylabel('Magnitude(dB)');
grid on;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -