matlab 传递函数 仿真,利用S-Function实现传递函数

For a model

with Nx states, Ny outputs, and Nu inputs:

a is an Nx-by-Nx real- or complex-valued matrix.

b is an Nx-by-Nu real- or complex-valued matrix.

c is an Ny-by-Nx real- or complex-valued matrix.

d is an Ny-by-Nu real- or complex-valued matrix.

To set D = 0 , set d to the scalar 0 (zero), regardless of the

dimension.

离散模型:

sys = ss(a,b,c,d,Ts) creates the discrete-time model

a4c26d1e5885305701be709a3d33442f.png

with sample time Ts (in seconds). Set Ts = -1 or Ts = [] to leave

the sample time unspecified.

1.3MATLAB tf2ss函数命令:

将传递函数模型转化为状态空间模型,单输入单输出系统转换如下:

a4c26d1e5885305701be709a3d33442f.png

利用该命令不仅可以转换SISO系统也可以转换MIMO系统,如下MISO系统也可以:

a4c26d1e5885305701be709a3d33442f.png

den= [0 2

3; 1 2 1];

num= [1 0.4 1];

[A,B,C,D] = tf2ss(den,num)

结果:

A =

-0.4000

-1.0000

1.0000

0

B =

1

0

C =

2.0000

3.0000

1.6000

0

D =

0

1

2、实例仿真

2.1假设工业过程某传递函数:

a4c26d1e5885305701be709a3d33442f.png

den= [1.5];

num= [1 5 1];

[A,B,C,D] = tf2ss(den,num)

结果:

a

=

x1

x2

x1

-5  -1

x2

1

0

b =

u1

x1

1

x2

0

c =

x1

x2

y1

0

1.5

d =

u1

y1

0

所以有:

a4c26d1e5885305701be709a3d33442f.png

2.2修改S-Function模板参数:

从结果可以看出,系统有两个状态,没有离散状态,输入1个,输出1个,无直通反馈,一种采用时间,打开模板,复制代码。

function[sys,x0,str,ts,simStateCompliance]

= sfuntmpl(t,x,u,flag)【一个主函数,需修改原函数名:sfuntmpl】

%SFUNTMPL General MATLAB S-Function Template

%  With MATLAB S-functions, you

can define you own ordinary differential

%  equations (ODEs), discrete

system equations, and/or just about

%  any type of algorithm to be

used within a Simulink block diagram.

%

%  The general form of an MATLAB

S-function syntax is:

%

[SYS,X0,STR,TS,SIMSTATECOMPLIANCE]

= SFUNC(T,X,U,FLAG,P1,...,Pn)

%

%  What is returned by SFUNC at

a given point in time, T, depends on the

%  value of the FLAG, the

current state vector, X, and the current

%  input vector, U.

%

%  FLAG

RESULT

DESCRIPTION

%  -----

------

--------------------------------------------

%  0

[SIZES,X0,STR,TS]

Initialization, return system sizes in

SYS,

%

initial

state in X0, state ordering strings

%

in

STR, and sample times in TS.

%  1

DX

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值