传递函数的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;}

1 / 6
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功