c语言一阶低通滤波器仿真(一阶低通滤波器系统函数)
大家好,今日小蚪来为大家解答以上的问题。c语言一阶低通滤波器仿真,一阶低通滤波器系统函数很多人还不知道,现在让我们一起来看看吧!
1、能实行,c语言不能显示图像,但是你要懂得如何用c调用matlab,过程比较复杂,这个程序任何参数都可以用,不限制#include#include#include#include#includedouble calcN(double fp,double ap, double fs, double as){double i = pow(10,(as/10)) - 1;double tmp = ap/10;double j = pow(10,tmp) - 1;double k = log10((i/j));double t = log10(fs/fp);double N = 0.5k/t + 1;return N;};int main(void){int fp,ap,fs,as;printf("请输入fp:");scanf("%d", &fp);printf("请输入ap:");scanf("%d", &ap);printf("请输入fs:");scanf("%d", &fs);printf("请输入as:");scanf("%d", &as);int f = calcN(fp, ap, fs, as);printf("N=%dchar lin[40];char str = "N=0";lin[0]='0';char in[4];itoa(f,in,10);strcat(lin,str);strcat(lin,in);strcat(lin, ";");///////////////////////////////////////////////////////////Engine ep;if(!(ep = engOpen(NULL))){printf("open failed! please try again}engSetVisible(ep, 0);//mxArray xx = mxCreateDoubleMatrix(1,N,mxREAL);// mxArray yy = mxCreateDoubleMatrix(1,N,mxREAL);// memcpy(mxGetPr(xx),Nsizeof(double));// memcpy(mxGetPr(yy),Nsizeof(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([0 2 0 1])");engEvalString(ep, "xlabel('w/wc');");engEvalString(ep, "ylabel('|H(jw)|^2');");engEvalString(ep, "title('Butterworth og filter prototype');");engEvalString(ep, "grid;");getchar();//mxDestroyArray(xx);// mxDestroyArray(yy);// engClose(ep);return 0;}。
本文到这结束,希望上面文章对大家有所帮助。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系 836084111@qq.com 删除。