# How does function c2d in MATLAB manage fractional delay?

the function c2d allows to convert a continuous laplace transfer function to a discrete z-transform transfer function. The base method is the Zero Order Holder. In example:

   s=tf('s');
P=3/(3+s);
Pd=c2d(P,0.1); % 0.1 is the sampling time


Produces

$$\frac{0.25918178 }{z - 0.74081822068}$$

$$0.74081822068 = e^{-0.1 \ \cdot \ 3}$$ as expected.

If we had a delay to the tf such as

$$e^{-2 s} \ \frac{3}{3+s}$$

the conversion will result obviously in:

$$z^{-20} \ \frac{0.25918178 }{z - 0.74081822068}$$

But if we introduce a delay not multiple of $$0.1$$ like this:

$$e^{-1.95 \ s} \ \frac{3}{3+s}$$

it will produce:

$$z^{-20} \ \frac{0.1393 z + 0.1199}{z - 0.7408}$$

As stated here, for "ZOH Method for Systems with Time Delays":

1. Decomposes the delay $$\tau$$ as $$\tau=kT+\rho$$ with $$0\le\rho<\tau$$
2. Absorbs the fractional delay $$\rho$$ into $$H(s)$$.

I ask how it is done the second step (if it is known), so how are calculated the coefficient of the numerator

$$0.1393 z + 0.1199$$

and why that algorithm adds a zero to the transfer function and increases the order of the numerator to compensate the fractional delay. Actually, the algorithm seems provide good results:

Thank you.

• Can I show you how to do $\LaTeX$ markup for your math? And then you'll use that in the future? Commented Nov 10, 2023 at 16:22
• @robertbristow-johnson of course, thank you very much, sorry, it is my first question! Commented Nov 10, 2023 at 16:27
• Hay, just FYI, you had the $z$ is the numerator in your original posting. Removing it from the numerator is just like multiplying by $z^{-1}$, which adds a delay of one sample to the transfer function. Does that enter into your accounting of total delay? Commented Nov 10, 2023 at 18:47
• Sorry @robertbristow-johnson I do not understand your point. I need to find $${(1-z^{-1}) \mathcal{Z}{ \left\\{ \mathcal{L^{-1}} \left\\{ \frac {1}{s} \left(\frac{3}{3+s} \right) \right\\}\right\\}}}$$ and this result in $$\frac{0.25918178}{z−0.74081822068}$$ . No z at numerator. Commented Nov 14, 2023 at 10:47
• Is this the expression you meant to say? $$(1-z^{-1}) \mathcal{Z} \left\{ \mathscr{L^{-1}} \left\{ \frac{1}{s} \left( \frac{3}{3+s} \right) \right\} \right\}$$ Commented Nov 15, 2023 at 22:08

The zero-order hold (ZOH) discretization is the same as the step-invariant method, which means that the step response of the discrete-time system equals the continuous-time step response at the sample instants. That's what is shown in the figure in your question.

The calculation of the discrete-time transfer function is performed as follows: factoring out a delay of $$20$$ samples, we're left with the following continuous-time transfer function:

$$H(s)=\frac{3e^{\tau s}}{s+3},\qquad \tau=0.05\tag{1}$$

The Laplace transform of the step response is

$$G(s)=\frac{H(s)}{s}=\frac{3e^{\tau s}}{s(s+3)}=e^{\tau s}\left(\frac{1}{s}-\frac{1}{s+3}\right)\tag{2}$$

The corresponding step response is

$$g(t)=\left(1-e^{-3(t+\tau)}\right)u(t+\tau)\tag{3}$$

For the ZOH (step-invariant) discretization we require the step response of the discrete-time system to be

\begin{align*} g_d[n] = g(nT) &= \left(1-e^{-3(nT+\tau)}\right)u(nT+\tau)\\ &= \left(1-e^{-3\tau}\left(e^{-3T}\right)^n\right)u[n]\tag{4} \end{align*}

where $$T$$ is the sampling interval. The discrete-time unit step sequence $$u[n]$$ equals $$u(nT+\tau)$$ because $$|\tau|.

The $$\mathcal{Z}$$-transform of $$(4)$$ is

$$G_d(z)=\frac{1}{1-z^{-1}}-\frac{e^{-3\tau}}{1-e^{-3T}z^{-1}}\tag{5}$$

The transfer function of the discrete-time system is

\begin{align*} H_d(z)=(1-z^{-1})G_d(z) &= 1-e^{-3\tau}\frac{1-z^{-1}}{1-e^{-3T}z^{-1}}\\ &= \frac{1-e^{-3\tau}+\left(e^{-3\tau}-e^{-3T}\right)z^{-1}}{1-e^{-3T}z^{-1}}\tag{6} \end{align*}

With $$\tau=0.05$$ and $$T=0.1$$ you obtain exactly the numbers returned by Matlab.

• If found myself Friday this same solution, I would write it, but you come earlier. Happy that I was right! Thank you. Commented Nov 13, 2023 at 16:21