|
Matlab 函数:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------------------------------------------------------------
1、多项式形式
假设传递函数如下,设离散时间ts为0.1s:
num = [2,0];
den = [4,0,3,-1];
ts = 0.1;
sysd = tf(num, den, ts);
%计算结果如下:
2 z
sysd = ---------------
4 z^3 + 3 z - 1
%-------------------------------------------------------------------------
2、零极点形式
假设 sys(z) =5* (z+1)/((z+2)(z+3)) , ts = 0.1s
z = [-1];
p = [-2; -3];
k = 5;
ts = 0.1;
sysd = zpk(z, p, k, ts);
%计算结果如下:
5 (z+1)
sysd = -----------
(z+2) (z+3)
%-------------------------------------------------------------------------
3、由零极点变成多项式形式
5 (z+1)
sysd = -----------
(z+2) (z+3)
z = [-1];
p = [-2; -3];
k = 5;
ts = 0.1;
sysd = zpk(z, p, k, ts);
sysd_poly = tf(sysd);
%计算结果如下:
5 z + 5
sysd_poly = -------------
z^2 + 5 z + 6
%-------------------------------------------------------------------------
4、由多项式变成零极点形式
num = [5,5];
den = [1,5,6];
ts = 0.1;
sysd = tf(num, den, ts);
sysd_zpk = zpk(sysd);
%计算结果如下:
5 (z+1)
sysd_zpk = -----------
(z+3) (z+2)
%-------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5、连续系统传递函数变成离散系统传递函数
c2d --- Convert model from continuous to discrete time
sysd = c2d(sysc,Ts)
sysd = c2d(sysc,Ts,method)
sysd = c2d(sysc,Ts,opts)
[sysd,G] = c2d(___)
其中:
sysc
— Continuous-time dynamic system, dynamic system modelTs
— Sample time , positive scalarmethod
— Discretization method'zoh'
(default) | 'foh'
| 'impulse'
| 'tustin'
| 'matched'
| 'least-squares'
例1:系统存在输入延时0.3s,离散化采用first-order-order近似('foh')、离散时间0.1s
H = tf([1 -1],[1 4 5],'InputDelay', 0.3);
Hd = c2d(H,0.1,'foh');
%结果如下:
s - 1
H = exp(-0.3*s) * -------------
s^2 + 4 s + 5
0.04226 z^2 - 0.01093 z - 0.03954
Hd = z^(-3) * ----------------------------------------
z^2 - 1.629 z + 0.6703
6、离散系统传递函数变成连续系统传递函数
%-----------------------------------------------------
例2
H = tf([1 -1],[1 1 0.3],0.1); % 采样时间为0.1s
Hc = d2c(H)
%计算结果:
z - 1
H = -------------
z^2 + z + 0.3
121.7 s + 2.904e-12
Hc = ---------------------
s^2 + 12.04 s + 776.7
%-----------------------------------------------------
Hz = c2d(Hc,0.1) % 再变成离散形式
%计算结果:
z - 1
Hz = -------------
z^2 + z + 0.3
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-24 03:21
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社