Chapter 6
Application to Control andCommunications
1
Chaparro — Signals and Systems using MATLAB 6.1
Pr. 6.1 (a) Nodal equations (circuit (a) in Fig. ??)[V1(s)/1
0
]=
[2 + s −1
−1 1 + s
][V2(s)
V3(s)
]
then
V3(s) =
det
[2 + s V1(s)
−1 0
]
det
[2 + s −1
−1 1 + s
] =V1(s)
s2 + 3s+ 1⇒ V3(s)
V1(s)=
1
s2 + 3s+ 1
(b) With the voltage follower (circuit (b) in Fig. ??)
V3(s)
V1(s)=V3(s)
V2(s)
V2(s)
V1(s)=
1
(s+ 1)(s+ 1)
there is no loading in this case so we obtain the desired transfer function.(c) Three stages with transfer functions
H1(s) =1000
s+ 1000, H2(s) =
1
s+ 1, H3(s) =
1
1000
as shown in circuit (c) of Fig. ?? will give the desired transfer function G(s).
-+
-+
-+
(a) (b)
(c)
1 !1 !
1 ! 1 ! 1 ! 1 !
1F 1F 1F 1F
1F10!3F1 !
v1(t) v1(t)
v2(t)
v2(t)v3(t) v3(t)
vi(t) vo(t)
! !!
!!
!
!
+
+
+
+
!
+
!
++
+
+
999 !
Figure 6.1: Cascade of two RC circuits (a) with loading and(b) no loading; (c) cascading 3 circuits toimplement given G(s)
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.2
Pr. 6.2 (a) Ωc = 40π × 103 rad/sec.
BP LPr(t)
!
cos(40! ! 103t)
s(t) m(t)p(t)
! BP LPr(t)
cos(40! ! 103t)
(a)
(b)x(t) y(t)
f (KHz)5 15 2520
1
4
LP BP
Figure 6.2: Possible AM receivers. BP, LP bandpass and lowpass ideal filters.
(b) Figure ??(a) shows the conventional AM receiver. The filters are LTI but the demodulator is LTV. If theideal bandpass filter has a magnitude α, a center frequency Ωc and a bandwidth coinciding with that of themessage, its output is
p(t) = αm(t) cos(Ωct)
and in frequency the output of the demodulator is
S(Ω) = 0.5 [P (Ω + Ωc) + P (Ω− Ωc)]
ReplacingP (Ω) =
α
2[M(Ω + Ωc) +M(Ω− Ωc)]
we getS(Ω) =
α
4[M(Ω) +M(Ω + 2Ωc) +M(Ω− 2Ωc)]
When passing s(t) through an ideal lowpass filter with unit gain and bandwidth 2πBW (rad/sec) we get asoutput (α/4)m(t) so that if α = 4 the output of the LP filter is m(t).(c) When we interchange the demodulator and the BP filter, we have the BP and the LP in cascade whichbeing ideal do not overlap and so result in that the output y(t) is always zero independent of x(t) and m(t).
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.3
Pr. 6.3 (a) Using Kirchkoff’s voltage laws we have
(i) Vi(s) = I(s)[R1 +R2] + Vo(s)
(ii) Vi(s) = R1I(s) + V−(s)
(iii) Vo(s) = −AV−(s)
where Vi(s), Vo(s), V−(s), I(s) are Laplace transforms of vi(t), vo(t), v−(t) and the current i(t) throughR1 and R2 (the current into the negative terminal is assumed zero). From (i)
I(s) =Vi(s)− Vo(s)R1 +R2
We then have in (ii)
(iv) Vi(s) =R1(Vi(s)− Vo(s))
R1 +R2+ V−(s)
which can be rewritten as
Vi(s)
[1− R1
R1 +R2
]=−R1Vo(s) + V−(s)(R1 +R2)
R1 +R2
−R2
R1Vi(s) = Vo(s) +
Vo(s)
A
(1 +
R2
R1
)which represents a negative feedback as shown in Fig. ??.Notice that (iv) becomes
Vi(s) Vo(s)!R2
R1
R1 + R2
AR1
+
!
Figure 6.3: Negative feedback equivalent of op-amp inverting amplifier.
Vi(s) =R1(Vi(s)− Vo(s))
R1 +R2− Vo(s)
A
after replacing in (iv) I(s) and equation (iii). If we let A → ∞ we get Vo(s)/Vi(s) = −R2/R1. Accordingto Fig. ?? the feedback signal is then zero giving the same result.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.4
Pr. 6.4 (a) The transfer function of the RC circuit is
Vo(s)
Vi(s)=
1/RC
s+ 1/(RC)
An equivalent negative feedback with a feed–forward transfer function G(s), and feedback transfer functionH(s) = 1 gives
Vo(s)
Vi(s)=
G(s)
1 +G(s)
Comparing the two we get that G(s) = 1/(RCs). Considering an integrator has a transfer functio 1/s thenwe have the equivalent representations for the RC circuit shown in Fig. ??.
+
!vi(t) vo(t)
1RC
!(.)dt
e(t)
Figure 6.4: Negative feedback equivalent of RC circuit.
(b) If vi(t) = Au(t), Vi(s) = A/s, then
Vo(s) =A/RC
s(s+ 1/(RC))=B
s+
C
s+ 1/RC
Since 1/RC > 0, i.e., the pole of Vo(s) is in the left-hand s-plane, then in the steady state vo(t) = B, where
B = Vo(s)s|s=0 =A/RC
1/(RC)= A
so that in the steady–state the error signal e(t) = vi(t)− vo(t) will be zero.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.5
Pr. 6.5(a) The transfer function of the RLC circuit with output Vo(s) = Vc(s) is
Vo(s)
Vi(s)=
1/Cs
R+ Ls+ 1/Cs=
1/LC
s2 + (R/L)s+ 1/LC
Letting, R = L = C = 1 for simplicity, the difference equation corresponding to the above transfer functionis
d2vo(t)
dt2+dvo(t)
dt+ vo(t) = vi(t)
which can be implemented using two integrators and an adder as shown in Fig. ??(a).(b) Letting the negative feedback be the one shown in Fig. ??(b), comparing it to the above transfer function(let again R = L = C = 1) we have
Vo(s)
Vi(s)=
1/s
1 + s+ 1/s=
G(s)
1 +G(s)H(s)
so that
G(s) =1
s
G(s)H(s) = s+1
s⇒ H(s) = s2 + 1
+
!
vi(t)
vo(t)e(t)vi(t)
∫(.)dt
∫(.)dt
vo(t)v(2)o (t) v(1)
o (t)
+
! !
G(s) =1s
H(s) = s2 + 1
(a)
(b)
Figure 6.5: Feedback equivalents of RLC circuit: (a) from differential equation, (b) from transfer function(R = L = C = 1).
(c) E(s) = Vi(s)− (s2 + 1)Vo(s) and
Vo(s) =1
s(s2 + s+ 1)=A
s+
Bs+ C
s2 + s+ 1
since s2 + s+ 1 = (s+ 1/2)2 + 3/4, its roots are s1,2 = −1/2± j√
3/4, in the left-hand s–plane, and thesteady state response is vo(t) = A where A = 1. The steady–state error is then
limt→∞
[e(t) = vi(t)−dvo(t)
dt− vo(t)] = 1− 0− 1 = 0.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.6
Pr. 6.6 (a) The transfer function of the feedback system is
Y (s)
X(s)=
G(s)
1 +H(s)G(s)=
1
1 + s/K
If we let G(s) = 1 then G(s)H(s) = s/K and H(s) = s/K. The lossy integrator (K > 0) corresponds to alow–pass filter with dc gain of 1.(b) If we let G(s) = s for H(s) = s/K then the transfer function of the feedback system is
Y (s)
X(s)=
G(s)
1 +H(s)G(s)=
s
1 + s2/K=
Ks
s2 +K
a band–pass filter.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.7
Pr. 6.7 (a) The transfer function of a stable second–order all–pass filter is of the form
T (s) =(s− α+ jβ)(s− α− jβ)
(s+ α+ jβ)(s+ α− jβ)=
(s− α)2 + β2
(s+ α)2 + β2=
N(s)
N(−s)
for α > 0 and β ≥ 0. The poles of T (s) are in the left-hand s-plane, and the poles an zeros are symmetric withrespect to the jΩ–axis, i.e., have the same imaginary parts and opposite real parts. If we call the numeratorN(s), the denominator of T (s) is N(−s).
For a negative feedback system with feed-forward transfer function G(s) and feedback transfer functionH(s) we have
G(s)
1 +G(s)H(s)=
N(s)
N(−s)which gives
G(s) =N(s)
N(−s)−N(s)H(s)
Thus if we let H(s) = 1, then
G(s) =N(s)
N(−s)−N(s)=
(s− α)2 + β2
(s+ α)2 + β2 − (s− α)2 − β2
=(s− α)2 + β2
4αs
For a positive feedback we let H(s) = −1 and then
G(s) =N(s)
N(−s) +N(s)=
(s− α)2 + β2
(s+ α)2 + β2 + (s− α)2 + β2
=(s− α)2 + β2
2(s2 + α2 + β2)
For the given
T (s) =s2 −
√2s+ 1
s2 +√
2s+ 1=
N(s)
N(−s)
we have also that α =√
2/2, β =√
2/2. Thus for the negative feedback implementation we let
H(s) = 1
G(s) =s2 −
√2s+ 1
2√
2s
and for the positive feedback implementation we let
H(s) = −1
G(s) =s2 −
√2s+ 1
2(s2 + 1)
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.8
Pr. 6.8 (a) The overall transfer function of the feedback system is
H(s) =G(s)
1 +KG(s)=
1
s2 + (K − 1)
If K > 1 the poles of H(s) are imaginary, s1,2 = ±j√K − 1, and the system is unstable. If 0 < K ≤ 1,
the poles of H(s) are s1,2 = ±√
1−K with one of them in the right-hand plane (for 0 < K < 1) or doubleat the origin of the s-planes (when K = 1) so the system is unstable. Thus it is not possible to stabilize thissystem with the proposed feedback system.(b) Using an all-pass filter Ha(s) = (s− 1)/(s+ 1), when cascading it with G(s) cancels the pole at s = 1
of G(s), causing the unstable behavior. The overall transfer function is
H(s) = G(s)Ha(s) =1
(s+ 1)2
Since the all-pass filter has a unity gain, the magnitude response of H(s) equals that of G(s).
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.9
Pr. 6.9 (a) Replacing H(s) we have
E(s) = X(s)
[1− G(s)
1 +G(s)
]= X(s)
1
1 + N(s)D(s)
=X(s)D(s)
D(s) +N(s)
If X(s) = 1/s then for the error to go to zero in the steady state, the roots of D(s) + N(s) should be in theleft–hand s-plane and D(s) must cancel the pole of E(s) at zero contributed by X(s), i.e., D(s) must be ofthe form D(s) = sD1(s).(b) For G(s) = 1/(s+ 1)(s+ 2) and X(s) = 1/s the Laplace transform of the error is
E(s) =D(s)
s(1 +D(s))=
(s+ 1)(s+ 2)
s(s2 + 3s+ 3)
According to the initial value theorem we have that
e(0) = lims→∞
sE(s) = lims→∞
(1 + 1/s)(1 + 2/s)
1 + 3/s+ 3/s2= 1
The poles of E(s) are s = 0 and s1,2 = −3/2 ± j√
3/4 since s2 + 3s + 3 = (s + 3/2)2 + 3/4. A partialfraction expansion for E(s) is
E(s) =A
s+
Bs+ C
s2 + 3s+ 3
where
A = sE(s)|s=0 =D(0)
1 +D(0)=
2
3
in this case the steady state error is 2/3. The error is not zero in the steady–state because D(s) does notcancel the pole due to X(s).
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.10
Pr. 6.10 (a) The product
Z(s) = P (s)Q(s) = 2 + 5s+ 6s2 + 5s3 + 2s4 + s5
results that are confirmed by the following script
%% Pr 6.10
clear all; clf
p=[1 1 1];
q=[2 3 1 1];
z=conv(p,q)
which gives
z = 2 5 6 5 2 1
the coefficients of Z(s).(b) The numerator and denominator coefficients (from lower to highest order) are computed by the followingscript
n=[1 1]
d1=[0 0 1];
d2=[25 8 1];
d3=[1 1];
d=conv(d3,conv(d1,d2))
n =1 1
d = 0 0 25 33 9 1
To find the inverse Laplace transform and to plot the response and the poles and zeros of Y (s) we use the followingscript:
syms s
D=d(3)*sˆ2+d(4)*sˆ3+d(5)*sˆ4+d(6)*sˆ5
y=ilaplace((1+s)/D)
figure(1)
subplot(211)
ezplot(y,[0 10000])
subplot(212)
splane(fliplr(n),fliplr(d))
(c) The function can be easily obtained using the above scripts
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.11
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
0
100
200
300
400
t
−8/625+8/625 exp(−4 t) cos(3 t)+...+1/25 t
−4 −3 −2 −1 0 1 2 3−4
−2
0
2
4
σ
jΩ
Figure 6.6: Inverse and poles/zeros for Y (z) .
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.12
Pr. 6.11 (a) The Laplace transform of the error is
E(s) = X(s)
[1− G(s)
1 +G(s)
]=
X(s)
1 +G(s)
= X(s)s(s+ 1)(s+ 2)
1 + s(s+ 1)(s+ 2)
(b) For x(t) = u(t) then
E1(s) =(s+ 1)(s+ 2)
1 + s(s+ 1)(s+ 2)
According to the final value theorem
e1ss = lims→0
sE1(s) = lims→0
s(s+ 1)(s+ 2)
1 + s(s+ 1)(s+ 2)= 0
(c) If x(t) = r(t), X(s) = 1/s2, we then have
E2(s) =(s+ 1)(s+ 2)
s(1 + s(s+ 1)(s+ 2))
and the final value theorem gives
e2ss = lims→0
sE2(s) = lims→0
(s+ 1)(s+ 2)
1 + s(s+ 1)(s+ 2)=
2
1= 2
larger than e1ss as r(t) is harder to follow that u(t).
%% Pr 6.11
clear all; clf
% computation e_1(t)
num=[0 1 3 2] % high order to low order
den=[1 3 2 1]% high order to low order
figure(1)
subplot(211)
[r,p]=pfeLaplace(num,den);
t=0:0.001:20;
e1=r(1)*exp(p(1).*t)+r(2)*exp(p(2).*t)+r(3)*exp(p(3).*t);
subplot(212)
plot(t,e1); grid; ylabel(’e_1(t)’); xlabel(’t’)
% computation of e_2(t)
num=[0 0 1 3 2] % high order to low order
den=[1 3 2 1 0]% high order to low order
figure(2)
subplot(211)
[r,p]=pfeLaplace(num,den);
t=0:0.001:20;
e2=r(1)*exp(p(1).*t)+r(2)*exp(p(2).*t)+r(3)*exp(p(3).*t)+r(4)*exp(p(4).*t);
subplot(212)
plot(t,e2);grid; ylabel(’e_1(t)’); xlabel(’t’)
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.13
−3 −2 −1 0 1 2 3−1.5
−1
−0.5
0
0.5
1
1.5
σ
jΩ
0 2 4 6 8 10 12 14 16 18 20−0.2
0
0.2
0.4
0.6
0.8
1
e 1(t)
t
−3 −2 −1 0 1 2 3−1.5
−1
−0.5
0
0.5
1
1.5
σ
jΩ
0 2 4 6 8 10 12 14 16 18 200
0.5
1
1.5
2
2.5
e 1(t)
t
Figure 6.7: Poles/zeros of E1(s) and e1(t) (left), poles/zeros of E2(s) and e2(t) (right).
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.14
Pr. 6.12 (a) The difference between the two arguments of the cosines is
2π(f0 − ν)
[L1 − L0
c
]=π
2
which givesL1 = L0 +
c
4(f0 − ν)= (10 + 38.5)× 103 = 48.5× 103 meters
(b) The received signal can be written
r(t) = 1.9 cos(2π × 1950t− 2π × 0.065)
with period T1 = 1/1950 = 5.13 × 10−4. The input signal is periodic of period T0 = 1/f0 = 1/2000 =
5× 10−4. The output of the channel has a different frequency than the input and as such it is not LTI. (b) Thefollowing script computes and plots x(t) and r(t) sampled at the given rate Fs.
%% Pr 6.12
clear all; clf
Fs=10000; Ts=1/Fs;
t=0:Ts:(1999)*Ts;
f0=2000;nu=50;L0=10000;L1=48500;c=3*10ˆ8;
x=cos(2*pi*f0*t);
r=cos(2*pi*(f0-nu).*(t-L0/c))+0.9*cos(2*pi*(f0-nu).*(t-L1/c))
figure(1)
subplot(211)
plot(t(1:100),x(1:100));ylabel(’x(t)’);xlabel(’t’)
subplot(212)
plot(t(1:100),r(1:100));ylabel(’r(t)’);xlabel(’t’)
(c) The following script shows how to do the multipath using parameters that change at random.
clear all;
Fs=10000; Ts=1/Fs;
t=0:Ts:(99)*Ts;
f0=2000;nu=50;L0=1000;L1=10000;c=3*10ˆ8;
figure(2)
for k=1:10,
eta=rand(1,1);
nuk=nu*eta;L0k=L0*eta;L1k=L1*eta;
alpha0=1-eta;alpha1=alpha0/10;
r=alpha0*cos(2*pi*(f0-nuk).*(t-L0k/c))+alpha1*cos(2*pi*(f0-nuk).*(t-L1k/c))
plot(t,r)
pause(0.1)
hold on
end
hold off
ylabel(’r(t)’);xlabel(’t’)
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.15
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01−1
−0.5
0
0.5
1x(
t)
t
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01−1.5
−1
−0.5
0
0.5
1
1.5
r(t)
t0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01
−1
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
1
r(t)
t
Figure 6.8: Input and received signals (left), received signal affected by random parameters of multipath.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.16
Pr. 6.13 (a) Using voltage division
Vc(s)
Vi(s)=
1/sC
1 + Ls+ 1/Cs=
1
LCs2 + Cs+ 1
which compared with the transfer function of the Butterworth filter gives
LC = 1
C =√
2
so that C =√
2 and L = 1/√
2.(b) Again by voltage division
VR(s)
Vi(s)=
1
1 + Ls+ 1/Cs=
Cs
LCs2 + Cs+ 1=
√2s
s2 +√
2s+ 1
This is a bandpass filter as it has s = 0 as a zero, so that for Ω = 0 this filter has zero magnitude, and asfrequency becomes infinity the frequency response is also zero.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.17
Pr. 6.14 The following script is used in finding the answers in this problem.
%% Pr 6.14
clear all; clf
alphamax=0.5 ;alphamin=30; Wp=1500; Ws=3500;
% Butterworth
D=(10ˆ(0.1*alphamin)-1)/(10ˆ(0.1*alphamax)-1);
E=Ws/Wp;
N=ceil(log10(D)/(2*log10(E)))
%Whp=Wp/(10ˆ(0.1*alphamax)-1)ˆ(1/(2*N))
Whp=Ws/(10ˆ(0.1*alphamin)-1)ˆ(1/(2*N))
alpha_p=10*log10(1+(Wp/Whp)ˆ(2*N))
alpha_s=10*log10(1+(Ws/Whp)ˆ(2*N))
% Chebyshev
N=ceil(acosh(Dˆ(0.5))/acosh(E))
eps=sqrt(10ˆ(0.1*alphamax)-1)
Whp1=Wp*cosh(acosh(1/eps)/N)
alpha_p= 10*log10(1+(epsˆ2)*(cos(N*acos(1)))ˆ2)
alpha_s=10*log10(1+(epsˆ2)*cosh(N*acosh(Ws/Wp))ˆ2)
%% Check with MATLAB
[N1,Whp1]=buttord(Wp,Ws,alphamax,alphamin,’s’)
[N2,Wn]=cheb1ord(Wp,Ws,alphamax,alphamin,’s’)
The orders and the half-power frequency (Butterworth) and the passband frequency (Chebyshev) are verifiedusing MATLAB functions buttord and cheb1ord.(a) The lowpass Butterworth filter that satisfies the specifications is of minimum order Nb = 6, while thecorresponding Chebyshev filter has minimum order Nc = 4. Typically for the same specifications Nc < Nb
(b) The half-power frequency of the designed Butterworth filter is Ωhp = 1787.4 (calculated so that the lossα(Ωp) = αmax). Another possible value for which α(Ωs) = αmin is Ωhp = 1968.4.
To compute the half-power frequency of the Chebyshev filter we need the ripple factor ε which we findto be 0.3493. We obtain Ωhp = 1639.7.(c) For the designed Butterworth filter with the first value of Ωhp we get
α(Ωp) = 0.5 dB
α(Ωs) = 35.023 dB
and for the second half-power frequency
α(Ωp) = 0.1635 dB
α(Ωs) = 30 dB
The values of the loss function for the Chebyshev filter are
α(Ωp) = 0.5 dB
α(Ωs) = 36.65 dB
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.18
These values do not depend on the half–power frequency but rather on Ωp which is the normalized frequency.(d) The formulas for the order of the Butterworth and the Chebyshev filters depend on the ratio of Ωp and Ωs,so the orders of the filters do not change.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.19
Pr. 6.15 Using the loss function
α(Ω) = α1 = 10 log10
(1 +
[Ω
Ωhp
]2N)⇒ Ωhp =
Ω
(100.1α1 − 1)1/2N
which gives
Ωhp =2000
(101.94 − 1)0.1= 1280.9 rad/sec.
Similarly, when α(Ωp) = αmax we have
Ωp = Ωhp(100.1αmax − 1)1/2N
which gives after replacing the values on the right term Ωp = 999.82 (rad/sec).
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.20
Pr. 6.16 Since the dc loss is not zero, the normalized loss specifications are
αmax = α1 − α(0) = 0.5
αmin = α2 − α(0) = 30
with a dc loss of 20 dB. The following script is used to find the anwers
%% Pr 6.16
clear all; clf
alphamax=0.5 ;alphamin=30; Wp=1500; Ws=3500;
alpha0=20;
% Butterworth
K=10ˆ(alpha0/20)
D=(10ˆ(0.1*alphamin)-1)/(10ˆ(0.1*alphamax)-1);
E=Ws/Wp;
N=ceil(log10(D)/(2*log10(E)))
Whp=Wp/(10ˆ(0.1*alphamax)-1)ˆ(1/(2*N))
alpha_p=10*log10(1+(Wp/Whp)ˆ(2*N))
alpha_s=10*log10(1+(Ws/Whp)ˆ(2*N))
% Chebyshev
N=ceil(acosh(Dˆ(0.5))/acosh(E))
eps=sqrt(10ˆ(0.1*alphamax)-1)
Whp1=Wp*cosh(acosh(1/eps)/N)
alpha_p= 10*log10(1+(epsˆ2)*(cos(N*acos(1)))ˆ2)
alpha_s=10*log10(1+(epsˆ2)*cosh(N*acosh(Ws/Wp))ˆ2)
alpha1=alpha0+10*log10(1+(epsˆ2)*cosh(N*acosh(0))ˆ2);
Kc=10ˆ(alpha1/20)
The following are the results
% Butterworth
K = 10 % dc gain
N =6 % minimum order
Whp =1.7874e+03 % half-power frequency
alpha_p = 0.5000 % loss at Wp
alpha_s =35.0228 % loss at Ws
% Chebyshev
N = 4 % min order
eps = 0.3493 % ripple factor
Whp1 = 1.6397e+03 % half-power frq
alpha_p = 0.5000 % loss at Wp
alpha_s = 36.6472 % loss at Ws
Kc =10.5925 % dc gain
Notice the computation of the dc gain in the Chebyshev filter. In this case the dc loss depends on the order ofthe filter and so it is not necessarily 0 dB, so to get the dc gain Kc we use
α(0) = 10 log10
[K2
1 + ε2C2N (0)
]= 20 log10K − 10 log10(1 + ε2C2
N (0))
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.21
as indicated in the script.(d) The minimum orders of the filters depend on the ratio of the two frequencies and since it remains the samethese do not change.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.22
Pr. 6.17 (a)–(c) The following script is used to design the three filters. To get the Butterworth or the Cheby-shev filters get rid of the comments symbols in front of the corresponding functions.
% Pr 6.17
clear all; clf
alphamax=0.5; alphamin=20; Wp=1000;Ws=2000;
W=0:2500;
% Butterworth
[Nb,Whp]=buttord(Wp,Ws,alphamax,alphamin,’s’)
[b,a]=butter(Nb,Whp,’s’);
% Chebyshev 1
%[Nc,Wn]=cheb1ord(Wp,Ws,alphamax,alphamin,’s’)
%[b,a]=cheby1(Nc,alphamax,Wn,’s’)
% Elliptic
%[Ne,Wn]=ellipord(Wp,Ws,alphamax,alphamin,’s’)
%[b,a]=ellip(Ne,alphamax,alphamin,Wn,’s’)
H=freqs(b,a,W);
alpha=-20*log10(abs(H));
M=length(H);
alpha1=alphamax*ones(1,M);
alpha2=alphamin*ones(1,M);
Ang=unwrap(angle(H));
figure(1)
subplot(221)
plot(W,abs(H));grid;axis([0 2500 0 1.1]);ylabel(’|H|’);xlabel(’\Omega’)
subplot(222)
plot(W,Ang);axis([0 2500 1.1*min(Ang) 1.1*max(Ang)]);grid
ylabel(’<H’);xlabel(’\Omega’)
subplot(223)
splane(b,a)
subplot(224)
plot(W,alpha); axis([0 2500 1.1*min(alpha) 1.1*max(alpha)])
ylabel(’\alpha(\Omega)’);xlabel(’\Omega’)
hold on
plot(W,alpha1,’r’)
hold on
plot(W,alpha2,’r’)
hold off
grid
The order of the three filters decreases from the Butterworth to the Chebyshev to the elliptic. The magnitudefrequency responses are equally good and the phase responses are approximately linear in the passband.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.23
0 500 1000 1500 2000 25000
0.2
0.4
0.6
0.8
1
|H|
Ω0 500 1000 1500 2000 2500
−6
−5
−4
−3
−2
−1
0
<H
Ω
−1000 −500 0
−1000
−500
0
500
1000
σ
jΩ
0 500 1000 1500 2000 25000
5
10
15
20
25
30
α(Ω
)
Ω
0 500 1000 1500 2000 25000
0.2
0.4
0.6
0.8
1
|H|
Ω0 500 1000 1500 2000 2500
−6
−5
−4
−3
−2
−1
0
<H
Ω
−400 −300 −200 −100 0−1000
−500
0
500
1000
σ
jΩ
0 500 1000 1500 2000 2500
10
20
30
40
α(Ω
)
Ω
0 500 1000 1500 2000 25000
0.2
0.4
0.6
0.8
1
|H|
Ω0 500 1000 1500 2000 2500
−4
−3
−2
−1
0
<H
Ω
−600 −400 −200 0−1500
−1000
−500
0
500
1000
1500
σ
jΩ
0 500 1000 1500 2000 25000
20
40
60
80
α(Ω
)
Ω
Figure 6.9: Frequency response, poles/zeros and loss functions of Butterworth, Chebyshev (top) and elliptic(bottom) filters.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.24
Pr. 6.18 (a) The Chebyshev low-pass filter is designed using the following script:
%% Pr 6.18
clear all; clf
alphamax=0.1; alphamin=60; Wp=1000;Ws=2000;
W=0:2500;
% Chebyshev 1
[Nc,Wn]=cheb1ord(Wp,Ws,alphamax,alphamin,’s’)
[b,a]=cheby1(Nc,alphamax,Wn,’s’)
H=freqs(b,a,W);
alpha=-20*log10(abs(H));
M=length(H);
alpha1=alphamax*ones(1,M);
alpha2=alphamin*ones(1,M);
alpha3=3*ones(1,M);
Ang=unwrap(angle(H));
figure(1)
subplot(221)
plot(W,abs(H));grid;axis([0 2500 0 1.1]); ylabel(’|H|’);xlabel(’\Omega’)
subplot(222)
plot(W,Ang);axis([0 2500 1.1*min(Ang) 1.1*max(Ang)])
ylabel(’<H’);xlabel(’\Omega’)
subplot(223)
splane(b,a)
subplot(224)
plot(W,alpha); axis([0 2500 1.1*min(alpha) max(alpha)])
ylabel(’\alpha(\Omega)’);xlabel(’\Omega’)
hold on
plot(W,alpha1,’r’)
hold on
plot(W,alpha2,’r’)
hold on
plot(W,alpha3,’g’)
hold off
grid
eps=sqrt(10ˆ(0.1*alphamax)-1)
Whp1=Wp*cosh(acosh(1/eps)/Nc)
(b) The half-power frequency is computed by finding first the ripple factor as shown in the following scriptthat follows the above script (i.e., it uses the necessary values computed before).
eps=sqrt(10ˆ(0.1*alphamax)-1)
Whp1=Wp*cosh(acosh(1/eps)/Nc)
The value obtained is Ωhp = 1051.9 (rad/sec). In the above script an additional line, corresponding to the 3db, is used to determine approximately this value.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.25
0 500 1000 1500 2000 25000
0.2
0.4
0.6
0.8
1
|H|
Ω0 500 1000 1500 2000 2500
−12
−10
−8
−6
−4
−2
0
<H
Ω
−300 −200 −100 0−1000
−500
0
500
1000
σ
jΩ
0 500 1000 1500 2000 2500
20
40
60
80
α(Ω
)Ω
Figure 6.10: Chebyshev low-pass: frequency response, poles/zeros, and loss.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.26
Pr. 6.19 The following script is used to compute the different signals, filters, and to plot them.
%% Pr 6.19
clear all; clf
syms t w
x=cos(100*pi*t)-2*cos(50*pi*t);
y=x+cos(120*pi*t);
figure(1)
subplot(211)
ezplot(x,[0:1]) % desired signal
subplot(212)
ezplot(y,[0:1]) % signal with hum
X=fourier(x);
% butterworth filter
N=5;
%wn=[2*pi*59.9 2*pi*60.1]; [b,a]=butter(N,wn,’stop’,’s’);C=1 % band-eliminating
% [b,a]=butter(2*N,110*pi,’high’,’s’);C=2 % high-pass
[b,a]=butter(N,[20*pi 90*pi],’s’);C=2 % band-pass
% frequency responses
W=0:1:150*pi;
Hm=abs(freqs(b,a,W));
figure(2)
subplot(211)
plot(W/(2*pi),Hm); axis([0 75 0 1.1]);xlabel(’f (Hz)’); ylabel(’|H|’)
M=2*N
% generation of frequency response from coefficients
n=M:-1:0;
U=(j*w).ˆn;
num=b*conj(U’); den=a*conj(U’);
H=num/den; % Butterworth LPF
% output of filter
Y1=X*H;
y1=real(ifourier(Y1,t));
subplot(212)
if C==1,
ezplot(y1,[0:1])
else
ezplot(x-y1,[0:1])
end
title(’denoised signal’)
The most natural of the three approaches is the one using the stopband filter, the other depend on informationon the desired signal that might or might not be available. The only needed information for the stopband filteris the frequency of the hum.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.27
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
−1
0
1
2
3
t
cos(100 π t)−2 cos(50 π t)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
−2
−1
0
1
2
3
4
t
cos(100 π t)−2 cos(50 π t)+cos(120 π t)
0 10 20 30 40 50 60 700
0.2
0.4
0.6
0.8
1
f (Hz)
|H|
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−2
−1
0
1
2
3
t
denoised signal
0 10 20 30 40 50 60 700
0.2
0.4
0.6
0.8
1
f (Hz)
|H|
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
−2
−1
0
1
2
3
t
denoised signal
0 10 20 30 40 50 60 700
0.2
0.4
0.6
0.8
1
f (Hz)
|H|
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
−2
−1
0
1
t
denoised signal
Figure 6.11: Top: original and original with hum signals. Bottom left to right: notch filter and filtered signal,high-pass filter and denoised signal, an bandpass filter and denoised signal.
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.28
Pr. 6.20
%% Pr 6.20
clear all; clf
%% signal generation
Ts=5/512;t1=0:Ts:1-Ts;t2=1:Ts:2-Ts;t3=2:Ts:5;M=length(t3);t=[t1 t2 t3];
x1=[t1 2-t2 zeros(1,512-length(t1)-length(t2))];
x2=[ones(1,200) zeros(1,512-200)];
[X1,W]=AFT(x1,Ts);
[X2,W]=AFT(x2,Ts);
%% low-pass filtering to get m1 and m2
N=10;whp=10;
[b,a]=butter(N,whp,’s’); % low-pass filter
H=freqs(b,a,W);
Z1=H.*X1;
[m1,t]=AIFT(Z1,Ts);
Z2=H.*X2;
[m2,t]=AIFT(Z2,Ts);
figure(1)
subplot(221)
plot(t,x1); title(’triangular pulse x_1(t)’);axis([0 5 -0.1 1.2]);grid
subplot(222)
plot(W,abs(X1));axis([-40 40 -0.1 1.5]); title(’spectrum |X_1|’);grid
hold on
plot(W,abs(H),’r’)
hold off
subplot(223)
plot(t,x2); title(’rectangular pulse x_2(t)’);axis([0 5 -0.1 1.2]);grid
subplot(224)
plot(W,abs(X2));axis([-40 40 -0.1 2.5]); title(’spectrum |X_2|’);grid
hold on
plot(W,abs(H),’r’)
hold off
figure(2)
subplot(221)
plot(t,m1); title(’message m_1(t)’);axis([0 5 -0.1 1.2]);grid
subplot(222)
plot(t,m2); title(’message m_2(t)’);axis([0 5 -0.5 1.2]);grid
subplot(223)
plot(W,abs(Z1));axis([-20 20 -0.1 1.5]);title(’|M_1|’); grid
subplot(224)
plot(W,abs(Z2));axis([-20 20 -0.1 2.5]);title(’|M_1|’); grid
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.29
%% received signal
m11=m1.*cos(20*t);
m22=m2.*cos(100*t);
u=m11+m22;
[U,W]=AFT(u,Ts);
%% bandpass filtering
Wn=[15,25];
[bb,aa]=butter(N,Wn,’s’) % bandpass filter
Hp=freqs(bb,aa,W);
M=Hp.*U;
[mhat,t]=AIFT(M,Ts);
figure(3)
subplot(221)
plot(W,abs(U));axis([-120 120 -0.1 1.5]);title(’Spectrum |U| of received signal and BPF’); grid
hold on
plot(W,abs(Hp),’r’)
hold off
subplot(222)
plot(t,mhat); title(’output of BPF’);axis([0 5 -1.1 1.1]);grid
%% demodularion and LPF
y=mhat.*cos(20*t);
[Y1,W]=AFT(y,Ts);
subplot(223)
plot(W,abs(Y1));axis([-60 60 -0.1 1.2]); grid; title(’LPF of demodulated signal’)
hold on
plot(W,abs(H),’r’)
hold off
M=H.*Y1;
[m,t]=AIFT(M,Ts);
subplot(224)
plot(t,3*m);axis([0 5 -0.5 1.5]);grid; title(’ recovered m_1(t)’); % scaled by 3
The following two functions are used too compute the direct and inverse Fourier transforms.
function [X,W] = AFT(x,Ts)
% Analog Fourier transform
% implemented using FFT
N=length(x);
X=fft(x)*Ts; W=[0:N-1]*2*pi/N-pi;W=W/Ts;
X=fftshift(X);
function [x,t] = AIFT(X,Ts)
% Analog Fourier transform
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.30
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
triangular pulse x1(t)
−40 −20 0 20 40
0
0.5
1
1.5spectrum |X
1|
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
rectangular pulse x2(t)
−40 −20 0 20 400
0.5
1
1.5
2
2.5spectrum |X
2|
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
message m1(t)
0 1 2 3 4 5−0.5
0
0.5
1
message m2(t)
−20 −10 0 10 20
0
0.5
1
1.5|M
1|
−20 −10 0 10 200
0.5
1
1.5
2
2.5|M
1|
−100 −50 0 50 100
0
0.5
1
1.5Spectrum |U| of received signal and BPF
0 1 2 3 4 5−1
−0.5
0
0.5
1output of BPF
−60 −40 −20 0 20 40 60
0
0.2
0.4
0.6
0.8
1
LPF of demodulated signal
0 1 2 3 4 5−0.5
0
0.5
1
1.5 recovered m
1(t)
Figure 6.12: Demodulation of AM signals.
% implemented using FFT
N=length(X);
X=fftshift(X);
x=real(ifft(X))/Ts;t=[0:N-1]*Ts;
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.31
Pr. 6.21 (a)
%% Pr 6.21
clear all; clf
%% signal generation
Ts=5/512;t1=0:Ts:1-Ts;t2=1:Ts:2-Ts;t3=2:Ts:5;M=length(t3);t=[t1 t2 t3];
x1=[t1 2-t2 zeros(1,512-length(t1)-length(t2))];
x2=[ones(1,200) zeros(1,512-200)];
[X1,W]=AFT(x1,Ts);
[X2,W]=AFT(x2,Ts);
%% low-pass filtering to get m1 and m2
N=10;whp=10;
[b,a]=butter(N,whp,’s’); % low-pass filter
H=freqs(b,a,W);
Z1=H.*X1;
[m1,t]=AIFT(Z1,Ts);
Z2=H.*X2;
[m2,t]=AIFT(Z2,Ts);
figure(1)
subplot(221)
plot(t,x1); title(’triangular pulse x_1(t)’);axis([0 5 -0.1 1.2]);grid
subplot(222)
plot(W,abs(X1));axis([-40 40 -0.1 1.5]); title(’spectrum |X_1|’);grid
hold on
plot(W,abs(H),’r’)
hold off
subplot(223)
plot(t,x2); title(’rectangular pulse x_2(t)’);axis([0 5 -0.1 1.2]);grid
subplot(224)
plot(W,abs(X2));axis([-40 40 -0.1 2.5]); title(’spectrum |X_2|’);grid
hold on
plot(W,abs(H),’r’)
hold off
figure(2)
subplot(221)
plot(t,m1); title(’message m_1(t)’);axis([0 5 -0.1 1.2]);grid
subplot(222)
plot(t,m2); title(’message m_2(t)’);axis([0 5 -0.5 1.2]);grid
subplot(223)
plot(W,abs(Z1));axis([-20 20 -0.1 1.5]);title(’|M_1|’); grid
subplot(224)
plot(W,abs(Z2));axis([-20 20 -0.1 2.5]);title(’|M_1|’); grid
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.32
%% received signal
m11=m1.*cos(50*t);
m22=m2.*sin(50*t);
s=m11+m22;
[S,W]=AFT(s,Ts);
figure(3)
subplot(221)
plot(W,abs(S));axis([-120 120 -0.1 1.5]);title(’Spectrum |S| of received signal’); grid
%% demodularion and LPF
y1=s.*cos(50*t);
y2=s.*sin(50*t);
[Y1,W]=AFT(y1,Ts);
[Y2,W]=AFT(y2,Ts);
subplot(222)
plot(W,abs(Y1));axis([-60 60 -0.1 1.2]); grid; title(’LPF of cos demodulated signal’)
hold on
plot(W,abs(H),’r’)
hold off
subplot(223)
plot(W,abs(Y2));axis([-60 60 -0.1 1.2]); grid; title(’LPF of sin demodulated signal’)
hold on
plot(W,abs(H),’r’)
hold off
M1=H.*Y1;
M2=H.*Y2;
[m1,t]=AIFT(M1,Ts);
[m2,t]=AIFT(M2,Ts);
subplot(224)
plot(t,m1);axis([0 5 -0.1 1]);grid; title(’ recovered m_1(t)’); hold on
plot(t,m2,’r’);axis([0 5 -0.1 1]);grid; title(’ recovered m_2(t)’); hold off
legend(’m_1(t)’,’m_2(t)’); grid
The following two functions are used too compute the direct and inverse Fourier transforms.
function [X,W] = AFT(x,Ts)
% Analog Fourier transform
% implemented using FFT
N=length(x);
X=fft(x)*Ts; W=[0:N-1]*2*pi/N-pi;W=W/Ts;
X=fftshift(X);
Copyright 2010, Elsevier, Inc. All rights reserved.
Chaparro — Signals and Systems using MATLAB 6.33
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
triangular pulse x1(t)
−40 −20 0 20 40
0
0.5
1
1.5spectrum |X
1|
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
rectangular pulse x2(t)
−40 −20 0 20 400
0.5
1
1.5
2
2.5spectrum |X
2|
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
message m1(t)
0 1 2 3 4 5−0.5
0
0.5
1
message m2(t)
−20 −10 0 10 20
0
0.5
1
1.5|M
1|
−20 −10 0 10 200
0.5
1
1.5
2
2.5|M
1|
−100 −50 0 50 100
0
0.5
1
1.5Spectrum |S| of received signal
−60 −40 −20 0 20 40 60
0
0.2
0.4
0.6
0.8
1
LPF of cos demodulated signal
−60 −40 −20 0 20 40 60
0
0.2
0.4
0.6
0.8
1
LPF of sin demodulated signal
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1 recovered m
2(t)
m
1(t)
m2(t)
Figure 6.13: Demodulation of QAM signals.
function [x,t] = AIFT(X,Ts)
% Analog Fourier transform
% implemented using FFT
N=length(X);
X=fftshift(X);
x=real(ifft(X))/Ts;t=[0:N-1]*Ts;
Copyright 2010, Elsevier, Inc. All rights reserved.