低通滤波c语言
‘壹’ 在设计FIR数字低通滤波器器时,用MATLAB生成了c语言头文件,在编写单片机程序时该怎样利用那个头文件
再将matlab里边的卷积函数转成C,直接调用就行了~~~~
或者你直接用C语言使用for写个卷积函数,将B和信号做卷积。
real64_T是double,写函数的时候注意点~
‘贰’ 求教用C语言实现低通滤波器
float middle_filter(float middle_value [] , intcount)
{
float sample_value, data;
int i, j;
for (i=1; i for(j=count-1; j>=i,--j){
if(middle_value[j-1]=middle_value[j]{
data=middle_value[j-1];
middle_value[j-1]=middle_value[j]
middle_value[j]=data;
}
}
sample_value=middle_value(count-1)/2];
return(sample_value);
}
‘叁’ 求:c语言数字滤波器;要求:1Khz低通;20个数x0,x1,x2----x19;结果y0---y19
1,低通滤波器传函k*f^2/(s^2+s*f/Q+f^2),确定你的电压增压k和品质因数,还有截止频率f。我就以f=1k,q=0.707,k=1为例。
2,进行离散化。离散化方法以双线性变换为例。。。。然后得到Transfer function:
1.039e-005 z + 6.53e-006
------------------------
z^2 - 1.243 z + 0.2431
Sampling time: 0.001
3,然后就改写成差分方程。。。。把z^(-n)中的(-n)写成(k-n)即可。自己移相试试 就知道了。
‘肆’ 如何用c语言实现截止频率为200hz的巴特沃斯低通滤波器
/* 6th Order Low Pass Butterworth */
/* Bilinear Transformation with Prewarping */
/* Sample Frequency = 100.0 Hz */
/* Standard Form */
/* Arithmetic Precision = 4 Digits */
/* */
/* Pass Band Frequency = 35.00 Hz */
/* */
/******************************************************************************/
/* */
/* Input Variable Definitions: */
/* Inputs: */
/* invar float The input to the filter */
/* initvar float The initial value of the filter */
/* setic int 1 to initialize the filter to the value of initvar */
/* */
/* There is no requirement to ever initialize the filter. */
/* The default initialization is zero when the filter is first called */
float DigFil(invar, initval, setic)
float invar, initval; int setic;
{
float sumnum, sumden; int i;
static float delay[7] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0};
static float znum[7] = {
.1477,
.8864,
2.216,
2.955,
2.216,
.8864,
.1477
};
static float zden[6] = {
2.183e-02,
.2099,
.8779,
2.055,
2.91,
2.38
};
if (setic==1){
for (i=0;i<=6;i++) delay[i] = .1058*initval;
return initval;
}
else{
sumden=0.0;
sumnum=0.0;
for (i=0;i<=5;i++){
delay[i] = delay[i+1];
sumden += delay[i]*zden[i];
sumnum += delay[i]*znum[i];
}
delay[6] = invar-sumden;
sumnum += delay[6]*znum[6];
return sumnum;
}
}
‘伍’ y=x*wc/(s+wc)这个一阶低通滤波器用c语言代码如何实现呢
s32 tmp;
tmp = x- y;
y += tmp*Wc;
‘陆’ c语言设计巴特沃斯低通滤波器fp=9khz,fs=15khz,ap=1dB,as=70dB
能实行,c语言不能显示图像,但是你要懂得如何用c调用matlab,过程比较复杂,这个程序任何参数都可以用,不限制
#include<engine.h>
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
doublecalcN(doublefp,doubleap,doublefs,doubleas)
{
doublei=pow(10,(as/10))-1;
doubletmp=ap/10;
doublej=pow(10,tmp)-1;
doublek=log10((i/j));
doublet=log10(fs/fp);
doubleN=0.5*k/t+1;
returnN;
};
intmain(void)
{
intfp,ap,fs,as;
printf("请输入fp:");
scanf("%d",&fp);
printf("请输入ap:");
scanf("%d",&ap);
printf("请输入fs:");
scanf("%d",&fs);
printf("请输入as:");
scanf("%d",&as);
intf=calcN(fp,ap,fs,as);
printf("N=%d ",f);
charlin[40];
char*str="N= ";
lin[0]='