This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/Matlab/comm/lab1_0.m

15 lines
530 B
Matlab

Fs=1e4;N=1e4; %定义采样频率、FFT 长度
t=(0:N-1)/Fs; %定义时间向量
f=Fs*(-N/2:N/2-1)/N; %定义频谱自变量 f 向量
ft=200*(sinc(200*(t-0.6))).^2; %产生三角频谱信号
yt=ft.*cos(2000*pi*t);
F=fftshift(fft(yt,N))/N; %求频谱
AF=abs(F); %求幅度谱
AFdB=20*log10(AF); %求幅度谱/dB
subplot(311);plot(t,yt);
xlabel('t/s');grid on
axis([0.55,0.65,-10,210])
subplot(312);plot(f,AF);
ylabel('幅度谱');xlabel('f/Hz');grid on
subplot(313);plot(f,AFdB);
ylabel('对数幅度谱/dB');xlabel('f/Hz');grid on