行业资讯

行业资讯

通过我们的最新动态了解我们

滤波器代码(滤波器 代码)

发布时间:2023-05-18
阅读量:74

本文目录一览:

求:一个关于FIR带通滤波器的C语言设计程序 代码

short h[], short y[])

{

int i, j, sum; for (j = 0; j 100; j++) {

sum = 0;

for (i = 0; i 32; i++)

sum += x[i+j] * h[i];

y[j] = sum 15;

}

}

2

void fir(short x[], short h[], short y[])

{

int i, j, sum0, sum1;

short x0,x1,h0,h1; for (j = 0; j 100; j+=2) {

sum0 = 0;

sum1 = 0;

x0 = x[j];

for (i = 0; i 姿兆 32; i+=2){

x1 = x[j+i+1];

h0 = h[i];

sum0 += x0 * h0;

sum1 += x1 * h0;

x0 = x[j+i+2];

h1 = h[i+1];

sum0 += x1 * h1;

sum1 += x0 * h1;

}

y[j] = sum0 15;

y[j+1] = sum1 携迟迹隐租 15;

}

}

3

void fir(short x[], short h[], short y[])

{

int i, j, sum0, sum1;

short x0,x1,x2,x3,x4,x5,x6,x7,h0,h1,h2,h3,h4,h5,h6,h7; for (j = 0; j 100; j+=2) {

sum0 = 0;

sum1 = 0;

x0 = x[j];

for (i = 0; i 32; i+=8){

x1 = x[j+i+1];

h0 = h[i];

sum0 += x0 * h0;

sum1 += x1 * h0;

x2 = x[j+i+2];

h1 = h[i+1];

sum0 += x1 * h1;

sum1 += x2 * h1;

x3 = x[j+i+3];

h2 = h[i+2];

sum0 += x2 * h2;

sum1 += x3 * h2;

x4 = x[j+i+4];

h3 = h[i+3];

sum0 += x3 * h3;

sum1 += x4 * h3;

x5 = x[j+i+5];

h4 = h[i+4];

sum0 += x4 * h4;

sum1 += x5 * h4;

x6 = x[j+i+6];

h5 = h[i+5];

sum0 += x5 * h5;

sum1 += x6 * h5;

x7 = x[j+i+7];

h6 = h[i+6];

sum0 += x6 * h6;

sum1 += x7 * h6;

x0 = x[j+i+8];

h7 = h[i+7];

sum0 += x7 * h7;

sum1 += x0 * h7;

}

y[j] = sum0 15;

y[j+1] = sum1 15;

}

}

基于MATLAB的巴特沃斯低通滤波器的设计。求代码?

%%生成50hz和罩茄100hz叠加的正弦波

Fs=1000;

T=1/Fs;

L=200;

t=(0:L-1)*T;

y1=sin(2*pi*50*t);

y2=sin(2*pi*100*t);

y=y1+y2+randn(size(t));

subplot(5,1,1);

plot(t,y);

%%快速傅里叶变换

N=2^nextpow2(L);

Y=fft(y,N)/L;

f=Fs/2*linspace(0,1,N/2+1);

subplot(5,1,2);

plot(f,2*abs(Y(1:N/2+1)));

%%滤波器的设计 wp通带截止频率棚尘 ws阻带截止频率 rp通带最大衰减 as阻带最小衰减

%%滤掉100hz的信链闷禅号

wp=2*50/Fs;

ws=2*80/Fs;

rp=1;

as=10;

[N,wc]=buttord(wp,ws,rp,as);

[b,a]=butter(N,wc);

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

z=filter(b,a,y);

subplot(5,1,3);

plot(w,abs(H));

subplot(5,1,4);

plot(t,z);

%%对滤波后得到的正弦波进行快速傅里叶变换

N1=2^nextpow2(L);

Y1=fft(z,N1)/L;

f1=Fs/2*linspace(0,1,N1/2+1);

subplot(5,1,5);

plot(f1,2*abs(Y1(1:N1/2+1)));

带通滤波器matlab代码

% 用切比雪夫最佳一致逼近设计线性相位FIR带通滤波器;

%信号为0.5hz, 0.9hz, 1.1hz和1.5hz的正统信号叠加组成

%通带为[0.9,1.1]

%频谱分辨率与信号实际长度N成正比

clear all;

f1=0.5;f2=0.9;f3=1.1;f4=1.5;t=0:1203;N=length(t);fs=10;M=512;

x1=sin(2*pi*(f1/fs)*t)+sin(2*pi*(f2/乱粗fs)*t)+sin(2*pi*(f3/fs)*t)+sin(2*pi*(f4/fs)*t);

figure(1);

subplot(211);plot(t,x1);title('原信号');

y=fft(x1);

f=(0:1/N:1/2-1/N)*fs;

subplot(212);plot(f,abs(y(1:N/2)));grid;xlabel('hz');%处理前频谱

wc1=2*f2/fs;wc2=2*f3/fs;wc3=2*f4/fs;%归一化角频率,用于下面旁桥的f1

f1=[0 wc1-0.05 wc1 wc2 wc2+0.05 1];

A=[0 0 1 1 0 0];%设置带通或带阻,1为带通,0为带阻

weigh=[1 1 1 ];%设置通带和阻带的权重

b=remez(60,f1,A,weigh);%传函分子

h1=freqz(b,1,M);%幅频运陪猛特性

figure(2)

f=(0:1/M:1-1/M)*fs/2;

subplot(211);plot(f,abs(h1));grid;title('带通');

x2=filter(b,1,x1);

S1=fft(x2);

f=(0:1/N:1/2-1/N)*fs;

subplot(212);plot(f,abs(S1(1:N/2)));grid;xlabel('hz');%处理后频谱

关键词:滤波器的设计 带通滤波器 滤波器代码 滤波器的 巴特沃斯低通滤波器

相关新闻

一点销电子网

Yidianxiao Electronic Website Platform

Tel:0512-36851680
E-mail:King_Zhang@Lpmconn.com
我们欢迎任何人与我们取得联系!
请填写你的信息,我们的服务团队将在以您填写的信息与您取得联系。
*您的姓名
*电话
问题/建议
承诺收集您的这些信息仅用于与您取得联系,帮助您更好的了解我们。