您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 机械/模具设计 > 传递函数的C语言实现
s=tf('s')Transferfunction:ssys=1/(3*s+1)Transferfunction:1-------3s+1bode(sys)c2d(sys,0.0002,'tustin')Transferfunction:3.333e-005z+3.333e-005-------------------------z-0.9999Samplingtime(seconds):0.0002Y/X=3.333e-005+3.333e-005Z(-1)-------------------------1-0.9999Z(-1)Y(1-0.9999Z(-1))=X(3.333e-005+3.333e-005Z(-1))Y=X*3.333e-005X+3.333e-005X(-1)+0.9999Y(-1)按照这个方程编写不对,因为系数精度太差了[ab]=tfdata(ans,'v')a=1.0e-004*0.3333222225925800.333322222592580b=1.000000000000000-0.999933335555481这才是差不多的系数step(sys)holdonstep(ans)02468101214161800.10.20.30.40.50.60.70.80.91StepResponseTime(seconds)Amplitudesysansplot(y)holdonplot(test(1:50001))0123456x10400.10.20.30.40.50.60.70.80.91data1data2//CTransFunc.cpp:Definestheentrypointfortheconsoleapplication.//#includestdafx.h#includestdio.h#includemath.hdoubleCTransFunc(doubledInput){staticdoubleInput[2]={0.0,0.0};staticdoubleOutput[2]={0.0,0.0};Input[0]=dInput;Output[0]=Input[0]*(0.0000333322222592580)+(0.0000333322222592580)*Input[1]+0.999933335555481*Output[1];Output[1]=Output[0];Input[1]=Input[0];returnOutput[0];}intmain(intargc,char*argv[]){inti=0;FILE*pFile=NULL;pFile=fopen(test.txt,w+);for(i=0;i200000;i++){fprintf(pFile,%f\n,CTransFunc(1.0));}fclose(pFile);return0;}
本文标题:传递函数的C语言实现
链接地址:https://www.777doc.com/doc-2722308 .html