频率分析

  • 格式:doc
  • 大小:93.50 KB
  • 文档页数:4

正弦波:

clear all;

clc

t=0:0.0005:0.03;

x=20*sin(10*pi*20*t)+50*cos(400*pi*t);

subplot(2,2,1);

plot(t,x)

fs=2000;

N=10;

n=0:9;

xn=20*sin(10*pi*20*n/fs)+50*cos(400*pi*n/fs);

subplot(2,2,2);

stem(n,xn)

xk=fft(xn);

k=0:9;

subplot(2,2,3);

stem(k*fs/N,2*abs(xk)/N)

方波:

fs=1000;

N=20;

n=0:N-1;

xn=[1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];

subplot(2,2,1);

stem(n,xn)

xk=fft(xn);

k=0:N-1;

subplot(2,2,2);

stem(k*fs/N,abs(xk))

三角波:

k=0:N-1;

subplot(2,2,2);

stem(k*fs/N,abs(xk))

fs=1000;

N=20;

n=0:N-1;

xn=[-5,-4,-3,-2,-1,0,1,2,3,4,5,4,3,2,1,0,-1,-2,-3,-4];

subplot(2,2,1);

stem(n,xn)

xk=fft(xn);

k=0:N-1;

subplot(2,2,2);

stem(k*fs/N,abs(xk));

[H W]=freqz(b,a);

FS=64000;

N=3;

b0=0.00242862;

b1=0.00728585;

b2=0.00728585;

b3=0.00242862;

a0=1;

a1=2.41295;

a2=-1.98603;

a3=0.553648;

b=[b0,b1,b2,b3];

a=[a0,a1,a2,a3];

[H W]=freqz(b,a);

plot(W/pi)