|
F=input('三角波分辨率F=');
fh=input('三角波信号最高频率fh=');
T=1./(2*fh);
t=1./F;
N=t./T;
fs=(0:N-1)*2*fh/N;
n=linspace(0,t,N);
x=sawtooth(2*pi*fh*n,0.5);
y=fft(x);
figure;
subplot(2,1,1);
stem(fs,abs(y));
xlabel('fs');
ylabel('|X(K)|');
title('三角波离散幅频图');
subplot(2,1,2);
stem(fs,angle(y));
xlabel('fs');
ylabel('φ(K)');
title('三角波离散相频图'); |