9t.m

来自「包含50个数字信号处理方面的matlab程序」· M 代码 · 共 34 行

M
34
字号
clear;
clc;
N1=40;
n=0:1:N1-1;
t=0.01*n;
x=2*sin(4*pi*t)+5*cos(16*pi*t);
x1=fft(x);
magx1=abs(x1);
w=2*pi/N1*n;
subplot(3,1,1);   
plot((w*100)/(2*pi),magx1);title('DFT幅度');
axis([0,25,0,200]);
N2=60;
n=0:1:N2-1;
t=0.01*n;
x=2*sin(4*pi*t)+5*cos(16*pi*t);
x2=fft(x);
magx2=abs(x2);
w=2*pi/N2*n;
subplot(3,1,2);   
plot((w*100)/(2*pi),magx2);title('DFT幅度');
axis([0,25,0,200]);
N3=128;
n=0:1:N3-1;
t=0.01*n;
x=2*sin(4*pi*t)+5*cos(16*pi*t);
x3=fft(x);
magx3=abs(x3);
w=2*pi/N3*n;
subplot(3,1,3);   
plot((w*100)/(2*pi),magx3);title('DFT幅度');
axis([0,25,0,400]);

⌨️ 快捷键说明

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