Problems 55
0.4. Backward difference—MATLAB
Another definition for the finite difference is the backward difference:
1 [x(nTs)]=x(nTs)−x((n− 1 )Ts)
( 1 [x(nTs)]/Tsapproximates the derivative ofx(t).)
(a) Indicate how this new definition connects with the finite difference defined earlier in this chapter.
(b) Solve Problem 0.3 with MATLAB using this new finite difference and compare your results with the
ones obtained there.
(c) For the value ofTs=0.1, use the average of the two finite differences to approximate the derivative of
the analog signalx(t). Compare this result with the previous ones. Provide an expression for calculating
this new finite difference directly.
0.5. Differential and difference equations—MATLAB
Find the differential equation relating a current sourceis(t)=cos( 0 t)with the currentiL(t)in an inductor,
with inductanceL=1 H, connected in parallel with a resistor ofR= 1 (see Figure 0.26). Assume a zero
initial current in the inductor.
(a) Obtain a discrete equation from the differential equation using the trapezoidal approximation of an
integral.
(b) Create a MATLAB script to solve the difference equation forTs=0.01and three frequencies for
is(t), 0 =0.005π, 0.05π, and0.5π. Plot the input current sourceis(t)and the approximate solution
iL(nTs)in the same figure. Use the MATLAB functionplot. Use the MATLAB functionfilterto solve the
difference equation (usehelpto learn aboutfilter).
(c) Solve the differential equation using symbolic MATLAB when the input frequency is 0 =0.5π.
(d) Use phasors to find the amplitude ofiL(t)when the input isis(t)with the given three frequencies.
FIGURE 0.26
Problem 0.5. RL circuit: inputis(t)and output
iL(t).
is(t)
iL(t)
1 Ω 1H
0.6. Sums and Gauss—MATLAB
Three rules in the computation of sums are
n Distributive law:
∑
k
cak=c
∑
k
ak
n Associative law:
∑
k
(ak+bk)=
∑
k
ak+
∑
k
bk