當前位置:首頁 » 編程語言 » 低通濾波c語言

低通濾波c語言

發布時間: 2024-01-28 20:28:36

『壹』 在設計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]='';

charin[4];

itoa(f,in,10);

strcat(lin,str);

strcat(lin,in);

strcat(lin,";");

///////////////////////////////////////////////////////////

Engine*ep;

if(!(ep=engOpen(NULL)))

{

printf("openfailed!pleasetryagain ");

}

engSetVisible(ep,0);

//mxArray*xx=mxCreateDoubleMatrix(1,N,mxREAL);

//mxArray*yy=mxCreateDoubleMatrix(1,N,mxREAL);

//memcpy(mxGetPr(xx),N*sizeof(double));

//memcpy(mxGetPr(yy),N*sizeof(double));

//engPutVariable(ep,"xx",xx);

//engPutVariable(ep,"yy",yy);

engEvalString(ep,"n=0:0.01:2;");

engEvalString(ep,lin);

engEvalString(ep,"[z,p,k]=buttap(N);");

engEvalString(ep,"[b,a]=zp2tf(z,p,k);");

engEvalString(ep,"[H,w]=freqs(b,a,n);");

engEvalString(ep,"magH=(abs(H)).^2;");

engEvalString(ep,"plot(w,magH);");

engEvalString(ep,"axis([0201])");

engEvalString(ep,"xlabel('w/wc');");

engEvalString(ep,"ylabel('|H(jw)|^2');");

engEvalString(ep,"title('');");

engEvalString(ep,"grid;");

getchar();

//mxDestroyArray(xx);

//mxDestroyArray(yy);

//engClose(ep);

return0;

}

熱點內容
龍村m腳本 發布:2024-11-29 17:38:10 瀏覽:781
linuxc配置文件 發布:2024-11-29 17:08:31 瀏覽:826
wow刷碎片腳本 發布:2024-11-29 15:58:24 瀏覽:592
明小子源碼 發布:2024-11-29 15:15:30 瀏覽:144
蘋果8plus什麼配置 發布:2024-11-29 14:16:36 瀏覽:677
androidmvp結構 發布:2024-11-29 14:16:34 瀏覽:536
androidsqlite命令 發布:2024-11-29 14:04:38 瀏覽:156
信用卡分期演算法 發布:2024-11-29 13:50:56 瀏覽:808
安卓手機dll文件為什麼打不開 發布:2024-11-29 13:40:49 瀏覽:1003
百分之五十石碳酸怎麼配置 發布:2024-11-29 13:38:56 瀏覽:974