传递函数的C语言实现

更新时间:2023-11-01 03:51:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

>> s=tf('s')

Transfer function: s

>> sys=1/(3*s+1)

Transfer function: 1 ------- 3 s + 1

>> bode(sys)

>> c2d(sys,0.0002,'tustin')

Transfer function:

3.333e-005 z + 3.333e-005 ------------------------- z - 0.9999

Sampling time (seconds): 0.0002

Y/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)

按照这个方程编写不对,因为系数精度太差了

>> [a b]=tfdata(ans,'v') a =

1.0e-004 *

0.333322222592580 0.333322222592580 b =

1.000000000000000 -0.999933335555481

这才是差不多的系数

>> step(sys) >> hold on >> step(ans)

Step Response1sys0.90.80.70.6Amplitude ans0.50.40.30.20.10 024681012141618Time (seconds)

>> plot(y) >> hold on

>> plot(test(1:50001))

10.90.80.70.60.50.40.30.20.10 012345x 1064 data1data2

// CTransFunc.cpp : Defines the entry point for the console application. //

#include \#include \#include \

double CTransFunc(double dInput) { static double Input[2] ={0.0,0.0}; static double Output[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]; return Output[0]; }

int main(int argc, char* argv[]) { int i=0; FILE *pFile=NULL; pFile=fopen(\ for (i=0;i<200000;i++) { fprintf(pFile,\ } fclose(pFile); return 0;

}

本文来源:https://www.bwwdw.com/article/nbf2.html

Top