d2c not giving the same results for the same input

5 views (last 30 days)
Hi! im working with digital control loops and noticed that if try to use d2c to convert an z-tranfer function that was created by taking an s-transfer function and converting it to z, I get drastically different results than when I "type" the exact same z-transfer function and try to convert it to s with d2c.
Here is my code:
close all
clear all
clc
s = tf('s');
a0 = 29;
b1 = 10/a0;
b0 = 40/a0;
a3 = 1/a0;
a2 = 5/a0;
a1 = 33/a0;
Gsmodel_final = (b1*s + b0)/(a3*s*s*s + a2*s*s + a1*s + 1)
Gzmodel_final = c2d(Gsmodel_final,0.01)
%%
z = tf('z',0.01);
a_0 = -0.9512;
b_2 = 0.0004982/a_0;
b_1 = 1.788e-05/a_0;
b_0 = -0.0004771/a_0;
a_3 = 1/a_0;
a_2 = -2.948/a_0;
a_1 = 2.899/a_0;
Gz = (b_2*z*z +b_1*z +b_0)/(a_3*z*z*z + a_2*z*z +a_1*z + 1)
Gs = d2c(Gz,'zoh')
Please help! I have tryed everything

Answers (1)

Chidvi Modala
Chidvi Modala on 29 Jan 2020
c2d function is used to convert model from continuous to discrete. Since, continuous data is truncated into discrete domain, the converted model will contain some errors. Converting this model back to continuous model using d2c, will also have few discrepancies from original model.  For example,
Hc = tf(0.1182, [0.0778 1], 'InputDelay', 0.07);
Hd = c2d(Hc, 0.05);
Hdc = d2c(Hd);
step(Hc,'b-', Hd, 'r--', Hdc, 'k-x')
legend('show')
We can see that ‘InputDelay’ of the original system has not been preserved after the conversion. In the d2c conversion, the delay is restricted to be an integer multiple of Ts, which explains the discrepancy. The response of Hdc is only guaranteed to match that of Hd at t=k*Ts and knows nothing about the original continuous system Hc. Therefore, when we convert a continuous model to discrete using c2d, we cannot retrieve it exactly using c2d.

Categories

Find more on Dynamic System Models in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!