Using a hand calculation, determine the output for the following set of statements: int k, s[] =
{3, 8, 15, 21, 30, 41}; for (k=0; k
Solution
The answer to the 1st question is :
This will throw error as for printing the values of the array {} is used hence it will throw error
and the program is not compiled .
use the following printf statement to run the code successfully
printf(\"%d%d\ \",s[k],s[k+1]);
After using this printf the progam works as follows:
k=0
s[k]=3
s[k+1]=8
output=38
k=2
s[k]=15
s[k+1]=21
output=1521
k=4
s[k]=30
s[k+1]=41
output=3041
now k = 6 hence will come out of loop as k<=5 is false now the condition given in loop.
Using the Tustin equivalence with the prewarping method, fnd the dis.pdf
1. Using the Tustin equivalence with the prewarping method, fnd the discrete equivalent of the
following H(s): H s s s s s ( ) = + + + + 2 5 7 3 8 2 2 With h = 0.5, conduct a Bode plot
comparison of continuous, Tustin equivalent, and backward differences.
Solution
Tustin Approximation
The Tustin or bilinear approximation yields the best frequency-domain match between the
continuous-time and discretized systems. This method relates the s-domain and z-domain
transfer functions using the approximation:
z=esTs1+sTs/21sTs/2.
In c2d conversions, the discretization Hd(z) of a continuous transfer function H(s) is:
Hd(z)=H(s),s=2Tsz1z+1
Similarly, the d2c conversion relies on the inverse correspondence
H(s)=Hd(z),z=1+sTs/21sTs/2
When you convert a state-space model using the Tustin method, the states are not preserved. The
state transformation depends upon the state-space matrices and whether the system has time
delays. For example, for an explicit (E = I) continuous-time model with no time delays, the state
vector w[k] of the discretized model is related to the continuous-time state vector x(t) by:
w[kTs]=(IATs2)x(kTs)Ts2Bu(kTs)=x(kTs)Ts2(Ax(kTs)+Bu(kTs)).
Ts is the sample time of the discrete-time model. A and B are state-space matrices of the
continuous-time model.
Tustin Approximation with Frequency Prewarping
If your system has important dynamics at a particular frequency that you want the transformation
to preserve, you can use the Tustin method with frequency prewarping. This method ensures a
match between the continuous- and discrete-time responses at the prewarp frequency.
The Tustin approximation with frequency prewarping uses the following transformation of
variables:
Hd(z)=H(s),s=tan(Ts/2)z1z+1
This change of variable ensures the matching of the continuous- and discrete-time frequency
responses at the prewarp frequency , because of the following correspondence:
H(j)=Hd(ejTs)
Tustin Approximation for Systems with Time Delays
You can use the Tustin approximation to discretize SISO or MIMO continuous-time models with
time delays.
2. By default, the Tustin method rounds any time delay to the nearest multiple of the sample time.
Therefore, for any time delay tau, the integer portion of the delay, k*Ts, maps to a delay of k
sampling periods in the discretized model. This approach ignores the residual fractional delay,
tau - k*Ts.
You can to approximate the fractional portion of the delay by a discrete all-pass filter (Thiran
filter) of specified order. To do so, use the FractDelayApproxOrder option ofc2dOptions.
To understand how the Tustin method handles systems with time delays, consider the following
SISO state-space model G(s). The model has input delay i, output delay o, and internal delay .
The following figure shows the general result of discretizing G(s) using the Tustin method.
By default, c2d converts the time delays to pure integer time delays. The c2d command
computes the integer delays by rounding each time delay to the nearest multiple of the sample
time Ts. Thus, in the default case, mi = round(i /Ts), mo = round(o/Ts), and m = round(/Ts)..
Also in this case, Fi(z) = Fo(z) = F(z) = 1.
If you set FractDelayApproxOrder to a non-zero value, c2d approximates the fractional portion
of the time delays by Thiran filters Fi(z), Fo(z), and F(z).
The Thiran filters add additional states to the model. The maximum number of additional states
for each delay is FractDelayApproxOrder.
for the input delay i, the order of the Thiran filter Fi(z) is:
order(Fi(z)) = max(ceil(i /Ts), FractDelayApproxOrder).
If ceil(i /Ts) < FractDelayApproxOrder, the Thiran filter Fi(z) approximates the entire input
delay i. If ceil(i/Ts) > FractDelayApproxOrder, the Thiran filter only approximates a portion of
the input delay. In that case, c2d represents the remainder of the input delay as a chain of unit
delays z–mi, where
mi = ceil(i /Ts) – FractDelayApproxOrder.
c2d uses Thiran filters and FractDelayApproxOrder in a similar way to approximate the output
delay o and the internal delay .
When you discretizetf and zpk models using the Tustin method, c2d first aggregates all input,
output, and transfer delays into a single transfer delay TOT for each channel. c2dthen
approximates TOT as a Thiran filter and a chain of unit delays in the same way as described for
each of the time delays in ss models.
Zero-Pole Matching Equivalents
The method of conversion by computing zero-pole matching equivalents applies only to SISO
systems. The continuous and discretized systems have matching DC gains. Their poles and zeros
are related by the transformation:
zi=esiTszzz
where:
3. Zero-Pole Matching for Systems with Time Delays
You can use zero-pole matching to discretize SISO continuous-time models with time delay,
except that the method does not support ss models with internal delays. The zero-pole matching
method handles time delays in the same way as the Tustin approximation.
Tustin Approximation
The Tustin or bilinear approximation yields the best frequency-domain match between the
continuous-time and discretized systems. This method relates the s-domain and z-domain
transfer functions using the approximation:
z=esTs1+sTs/21sTs/2.
In c2d conversions, the discretization Hd(z) of a continuous transfer function H(s) is:
Hd(z)=H(s),s=2Tsz1z+1
Similarly, the d2c conversion relies on the inverse correspondence
H(s)=Hd(z),z=1+sTs/21sTs/2
When you convert a state-space model using the Tustin method, the states are not preserved. The
state transformation depends upon the state-space matrices and whether the system has time
delays. For example, for an explicit (E = I) continuous-time model with no time delays, the state
vector w[k] of the discretized model is related to the continuous-time state vector x(t) by:
w[kTs]=(IATs2)x(kTs)Ts2Bu(kTs)=x(kTs)Ts2(Ax(kTs)+Bu(kTs)).
Ts is the sample time of the discrete-time model. A and B are state-space matrices of the
continuous-time model.
Tustin Approximation with Frequency Prewarping
If your system has important dynamics at a particular frequency that you want the transformation
to preserve, you can use the Tustin method with frequency prewarping. This method ensures a
match between the continuous- and discrete-time responses at the prewarp frequency.
The Tustin approximation with frequency prewarping uses the following transformation of
variables:
Hd(z)=H(s),s=tan(Ts/2)z1z+1
This change of variable ensures the matching of the continuous- and discrete-time frequency
responses at the prewarp frequency , because of the following correspondence:
H(j)=Hd(ejTs)
Tustin Approximation for Systems with Time Delays
You can use the Tustin approximation to discretize SISO or MIMO continuous-time models with
time delays.
By default, the Tustin method rounds any time delay to the nearest multiple of the sample time.
Therefore, for any time delay tau, the integer portion of the delay, k*Ts, maps to a delay of k
sampling periods in the discretized model. This approach ignores the residual fractional delay,
4. tau - k*Ts.
You can to approximate the fractional portion of the delay by a discrete all-pass filter (Thiran
filter) of specified order. To do so, use the FractDelayApproxOrder option ofc2dOptions.
To understand how the Tustin method handles systems with time delays, consider the following
SISO state-space model G(s). The model has input delay i, output delay o, and internal delay .
The following figure shows the general result of discretizing G(s) using the Tustin method.
By default, c2d converts the time delays to pure integer time delays. The c2d command
computes the integer delays by rounding each time delay to the nearest multiple of the sample
time Ts. Thus, in the default case, mi = round(i /Ts), mo = round(o/Ts), and m = round(/Ts)..
Also in this case, Fi(z) = Fo(z) = F(z) = 1.
If you set FractDelayApproxOrder to a non-zero value, c2d approximates the fractional portion
of the time delays by Thiran filters Fi(z), Fo(z), and F(z).
The Thiran filters add additional states to the model. The maximum number of additional states
for each delay is FractDelayApproxOrder.
for the input delay i, the order of the Thiran filter Fi(z) is:
order(Fi(z)) = max(ceil(i /Ts), FractDelayApproxOrder).
If ceil(i /Ts) < FractDelayApproxOrder, the Thiran filter Fi(z) approximates the entire input
delay i. If ceil(i/Ts) > FractDelayApproxOrder, the Thiran filter only approximates a portion of
the input delay. In that case, c2d represents the remainder of the input delay as a chain of unit
delays z–mi, where
mi = ceil(i /Ts) – FractDelayApproxOrder.
c2d uses Thiran filters and FractDelayApproxOrder in a similar way to approximate the output
delay o and the internal delay .
When you discretizetf and zpk models using the Tustin method, c2d first aggregates all input,
output, and transfer delays into a single transfer delay TOT for each channel. c2dthen
approximates TOT as a Thiran filter and a chain of unit delays in the same way as described for
each of the time delays in ss models.
Zero-Pole Matching Equivalents
The method of conversion by computing zero-pole matching equivalents applies only to SISO
systems. The continuous and discretized systems have matching DC gains. Their poles and zeros
are related by the transformation:
zi=esiTszzz
where:
Zero-Pole Matching for Systems with Time Delays
You can use zero-pole matching to discretize SISO continuous-time models with time delay,
except that the method does not support ss models with internal delays. The zero-pole matching