如何绘制离散(z域)传递函数的斜坡响应?[MATLAB]



我正在比较连续(s域(传递函数与其等价离散(z域(函数的时间响应。我使用了c2d函数,使用了TustinZOHFOHImpulse-InvariantMatched这五种方法来离散TF。阶跃响应函数适用于所有传递函数(连续和离散(,但当我谈到斜坡响应时,MATLAB没有ramp()函数。

我在网上发现的一个简单技巧是使用step(),将TF除以s,它应该模拟斜坡响应step(G/s)。这对连续TF来说效果很好,但对其余的离散TF来说却有误差。

使用/时出错(第65行(采样时间必须一致。

如何修复此错误?

这是我的代码,第58行(最后一行(有问题

clc
clear all
close all
s=tf('s') %Defining s as laplace domain vairable
Ts=0.1 %Sample Time
%Continuous Transfer Function
G = (-40824*s^2 - 122472*s + 1.497*10^8)/(s^4 + 186*s^3 + 4.67*10^4*s^2 + 3.71*10^6*s + 1.452*10^8)
%Continuous to Discrete conversion
Gt = c2d(G,Ts, 'tustin')
Gi = c2d(G, Ts, 'impulse')
Gz = c2d(G, Ts, 'zoh')
Gf = c2d(G, Ts, 'foh')
Gm = c2d(G,Ts,'matched')
%Bode Plot (Frequency Response) for all methods
bode(G,Gt,Gi,Gz,Gf,Gm)
legend('Continuous','Tustin (Bilinear)','Impulse Invariant','Zero-Order Hold','First-Order Hold','Matched')
%Step (Time Response) for all methods
figure; step(G,Gt,Gi,Gz,Gf,Gm)
legend('Continuous','Tustin (Bilinear)','Impulse Invariant','Zero-Order Hold','First-Order Hold','Matched')
%Impulse (Time Response) for all methods
figure; impulse(G,Gt,Gi,Gz,Gf,Gm)
legend('Continuous','Tustin (Bilinear)','Impulse Invariant','Zero-Order Hold','First-Order Hold','Matched')
%Root-Locus for continuous TF
figure; rlocus(G)
legend('Continuous')
%Root-Locus for Tustin method TF
figure; rlocus(Gt)
legend('Tustin (Bilinear)')
%Root-Locus for Impulse Invariant method TF
figure; rlocus(Gi)
legend('Impulse Invariant')
%Root-Locus for Zero-Order Hold method TF
figure; rlocus(Gz)
legend('Zero-Order Hold')
%Root-Locus for First-Order Hold method TF
figure; rlocus(Gf)
legend('First-Order Hold')
%Root-Locus for Matched method TF
figure; rlocus(Gm)
legend('Matched')
%Ramp Response for continuous TF
step(G/s)
%Ramp Response for Tustin method TF
step(Gt/s)

对于斜坡响应,您可以使用以下选项:

t=0:0.1:10;
r=t; %this is your input -u
Ts=0.1 ;
lsim(G,r,t);
figure
Gt = c2d(G,Ts, 'tustin');
lsim(Gt,r)

其中G是连续TF。

最新更新