Académique Documents
Professionnel Documents
Culture Documents
Roland Priemer
University of Illinois at Chicago
The complex number is a very useful and important concept in many fields of science and engineering
and especially in almost all areas of electrical engineering. An important distinguishing feature of
MATLAB is its ability to work with the complex data type. In this chapter you will learn about the origin
of complex numbers, how MATLAB can to do arithmetic with complex numbers and how complex
numbers provide a convenient mechanism for representing signals and for system analysis.
Equation Chapter 6 Section 1
Complex numbers were invented as a resolution of the dilemma that can arise when we want to find the
solution or roots of
f ( x) a x 2 b x c 0 (6.1)
b c
x2 x 0
a a
2a
2
and adding and subtracting b gives
2 2
b b b c
x x
2
0
a 2a 2a a
The steps from (6.1) to (6.2) are called completing the square. Taking the square root of both sides of
(6.2) yields
b b2 4 a c b b 2 4 a c
x (6.3)
2a 4 a2 2a
The formula in (6.3) gives the two solutions of (6.1).
The factor, b 2 4 a c , is called the discriminant, and it may be positive, in which case there are
two distinct real roots of (6.1). If the discriminant is zero, then there are two real and equal roots.
Denote the two roots by x1 and x2 , and we can write the polynomial f ( x) as a product of two first
order factors given by
f ( x) a ( x x1 ) ( x x2 ) a ( x 2 ( x1 x2 ) x x1 x2 )
If the discriminant is negative, can we still write f ( x) as a product of two first order factors? In this
case, let us write (6.3) as
b b 2 4 a c b (1)(4 a c b 2 ) b 1 4 a c b 2
x
2a 2a 2a
Since 1 cannot have a real value, it is taken into account with a symbol, such as
j 1 (6.4)
and j 2 1 . Therefore, if the discriminant is negative, then the two roots of (6.1) are given by
b j 4 a c b 2
x (6.5)
2a
x j (6.6)
where , a real number, is called the real part of x , denoted by Re( x ) , and , a real number, is
called the imaginary part of x , denoted by Im( x) . This way of writing a complex number is called
the rectangular form. The set of all complex numbers is denoted by . A complex number can be a
real number, in which case the imaginary part is zero, and a complex number can be an imaginary
number, in which case the real part is zero. A common operation on a complex number is to change the
sign of the imaginary part. If two complex numbers differ only in the sign of their imaginary parts, then
these two numbers are said to be complex conjugates of each other. The complex conjugate of x in
(6.6) is denoted by x* , and it is given by
x* ( j )* j (6.7)
*
Notice that x* x . Also notice that the two complex zeros given by (6.5) of a quadratic polynomial
with real coefficients occur as a complex conjugate pair. Let us obtain the product of two first order
factors using a pair of complex conjugate roots to get
( x ( j ))( x ( j )) x 2 x jx x 2 j j x j 2
x 2 2 x ( 2 2 )
Example 6.1. Let us find the roots of (6.1) for some specific cases.
2 4 96 2 10
x 3, 2
4 4
Let x1 and x2 denote the roots obtained with the plus sign and minus sign, respectively. Therefore,
x1 3 and x2 2 . With the roots, we can factor the second order polynomial into a product of
two first order factors given by
f ( x) 2 x 2 2 x 12 2 ( x x1 ) ( x x2 ) 2( x 3)( x 2)
Since x x1 and x x2 make f ( x) equal zero, x1 and x2 are called the zeros of f ( x) .
80
60
40
y
20
-20
-6 -4 -2 0 2 4 6 8
x
Figure 6.1. Plot of a quadratic function that has two real zeros.
For another point of view, let us plot f ( x) versus x , which is shown in Figure 6.1. Here we see
that the real zeros of a polynomial are the values of x where the polynomial crosses the abscissa, the x-
axis, where y 0 . The MATLAB program that was used to obtain the plot in Fig. 6.1 is given in
Program 6.1.
where the symbol j is used to mean 1 . Let us verify that x1 1 j 2 and x2 1 j 2 are the
zeros of f ( x) . With x x1 we get
Similarly, we can verify that x2 is a zero of f ( x) . As with real zeros of f ( x) , f ( x) can be factored
into a product of two first order factors given by
f ( x) ( x x1 ) ( x x2 ) ( x 1 j 2)( x 1 j 2)
x 2 x j 2 x x 1 j 2 j 2 x j 2 ( j 2)( j 2)
x2 2x 5
Figure 6.2 shows f ( x) versus x, and we see that f ( x) does not cross the abscissa, because it has
complex zeros.
150
100
y
50
0
-10 -5 0 5 10
x
Fig. 6.2. Plot of a quadratic function that has a pair of complex conjugate zeros.
___________
6.2 Rectangular Form and Complex Arithmetic
Arithmetic with complex numbers is similar to arithmetic with real numbers. Let x1 1 j 1 and
x2 2 j 2 be two complex numbers. Table 6.1 lists several arithmetic properties.
In MATLAB it is very easy to work with complex numbers. MATLAB uses the symbols I or j for
1 .
Example 6.2. Using the MATLAB command window, the following statements demonstrate how
convenient it is to use MATLAB for work with complex numbers written in rectangular form.
In MATLAB, complex numbers can be elements of matrices. The following statements illustrate some of
the possibilities.
Example 6.3. In this example we will use a MATLAB program to apply the formula given by (6.3). Most
of the programs that we will write serve to illustrate various MATLAB features and operations.
However, when we write an application program that is intended to be used by others or the program
writer at a later time, it is useful to document the program such that its purpose and methods can be
easily determined. The following MATLAB program illustrates preferred program organization. While
we cannot assure with certainty that a program cannot fail, we must always strive to write programs
that provide the user an opportunity to test for the proper functioning of the program and a means to
terminate the program within the program development environment.
%
% EXAMPLE OF PROGRAM ORGANIZATION
%
% Program calc_roots.m
%
% Purpose:
% This program solves for the roots of a quadratic equation
% of the form: a*x^2 + b*x +c = 0. It finds real roots
% and complex roots of the equation.
%
% Program information
% Date Programmer Description
% 2/22/09 R. Priemer Original code, version 1.0
%
% Define variables
% a --coefficient of x^2 term
% b --coefficient of x term
% c --constant term
% disc --discriminant
% i_part --imaginary part
% r_part --real part
% x1 --first root
% x2 --second root
%
clear all; clc;
disp('This program solves for the roots of a quadratic equation');
disp('of the form: a*x^2 + b*x + c = 0.');
disp('To terminate this program,');
disp('enter zero when prompted for the coefficient a');
while 1 % this causes the while loop to execute endlessly
% Prompt user for equation coefficients
a=input('Enter the coefficient a: ');
if a == 0.0
break % user has terminated the while loop and the program
end
b=input('Enter the coefficient b: ');
c=input('Enter the coefficient c: ');
% Find the discriminant
disc=b^2-4*a*c;
% Check the discriminant
if disc > 0 % There are two real roots
d=sqrt(disc);
x1=(-b+d)/(2*a); % first root
x2=(-b-d)/(2*a); % second root
disp('The equation has two real roots:');
fprintf('x1= %f\n', x1); % Using floating point formatted print
fprintf('x2= %f\n', x2);
elseif disc == 0 % There are two real roots
x1=(-b)/(2*a); % x2 = x1
disp('The equation has two repeated real roots:');
fprintf('x1=x2= %f\n', x1);
else % There are two complex conjugate roots
r_part=(-b)/(2*a);
i_part=sqrt(abs(disc))/(2*a);
disp('The equation has two complex conjugate roots:');
fprintf('x1= %f +j %f\n', r_part, i_part);
fprintf('x2= %f -j %f\n', r_part, i_part);
end
end
disp('Program terminated');
The methods for formatted output used to print the results from this program are presented in Chapter
13. The execution of this program gives the following results.
Example 6.4. For polynomials with degree higher than 4, there are no formulas to find the roots.
However, there are numerical methods for root finding, and MATLAB has a built in function roots to find
the roots of a polynomial and another built in function poly to find the coefficients of a polynomial
given its roots. The following program shows how to use the functions: roots and poly.
The execution of this program gives the following results for the polynomial:
x 5 x 4 2 x 3 3x 2 4 x1 5 x 0 .
To find the roots of: x^N + a_N-1 * x^(N-1) + ... + a_1 * x^1 + a_0
Enter the polynomial degree and then the coefficients.
To terminate the program, enter zero degree.
Notice that complex roots appear in complex conjugate pairs. With the roots r (n) ,
n 1, 2, , N , we can write the polynomial as a product of N first order factors given by
N
f ( x) ( x r (n))
n 1
There is another way, called the polar form, to arithmetically define a complex number, which in many
circumstances is more convenient to work with than the rectangular form.
x
x
co m p le x p la n e
x
R e (x )
The point x can also be located by rotating a line of length, denoted by x , in the
counterclockwise direction from the positive abscissa by an angle, denoted by x . By projection we
have
x cos(x) (6.8)
x sin(x) (6.9)
Therefore
x 2 2 (6.10)
Therefore
x tan 1 (6.11)
and x is called the angle of x . Substituting (6.8) and (6.9) into the rectangular form of (6.6) gives
Now, let us consider the power series expansion for the exponential function e j , and we get
( j )0 ( j )1 ( j ) 2 ( j )3 ( j )4 ( j )5
e j
0! 1! 2! 3! 4! 5!
1 2 3 4 5
1 j j j
1! 2! 3! 4! 5!
2 4 1 3 5
e j
1 j (6.13)
2! 4! 1! 3! 5!
The real part of (6.13) is the power series expansion for cos( ) , and the imaginary part of (6.13) is the
power series expansion for sin( ) . Now, (6.13) becomes
With Euler's identity, the expression for the complex number given in (6.12) becomes
x x e j x (6.15)
This way of writing a complex number is call the polar form. With (6.10) and (6.11) we can convert a
complex number from rectangular to polar form, and with (6.8) and (6.9) we can convert a complex
number from polar to rectangular form. Table 6.2 lists several arithmetic properties of complex
numbers written in polar form.
x1 x x
x3 1 e j ( x1 x2 ) , x3 1 and x3 x1 x2
division x2 x2 x2
conjugation x
*
j x jx x*
x x e , x x e
*
, ( x1 x2 ) x x
* *
1
*
2 and 1 1*
x2 x2
Example 6.5. The following statements illustrate how convenient it is to work in MATLAB with complex
numbers written in polar form.
Euler’s identity in (6.14) can be written in several different ways. If we replace in (6.14) by
, then we get
e j cos( ) j sin( ) cos( ) j sin( ) (6.16)
Comparing (6.14) and (6.16) shows that conjugating a complex number changes the sign of its
angle. If we add (6.14) and (6.16), then we get
e j e j
cos( ) (6.17)
2
With (6.17) we can write cos( ) as the sum of two complex conjugate exponential functions. If
we subtract (6.16) from (6.14), then we get
e j e j e j e j e j ( /2) e j e j ( /2)
sin( )
j2 2e j /2 2
(6.18)
e j ( /2) e j ( /2)
cos( / 2)
2
With (6.18) we can write sin( ) as the sum of two complex conjugate exponential functions. Equations
(6.16), (6.17) and (6.18) are also called Euler’s identity.
Example 6.6. Let us verify Euler’s identities with the following MATLAB statements.
where , the independent variable, is expressed in radians. When goes through a change of 2
radians, then x will repeat itself, or
x ( ) x( r 2 )
Now, let us work with a sinusoidal function of time (time is expressed in seconds) given by
x(t ) A cos(0 t ) (6.19)
where 0 (expressed in radians/sec) is called the frequency of x (t ) , A , a positive number, is called the
amplitude of x (t ) , and is called the phase angle of x (t ) . Like sin( ) , this function will repeat itself
when 0 t goes through a change of 2 , where t is now the variable. The time interval, T0 , over
which x (t ) repeats itself is called the period of x (t ) , and we write
Example 6.7. Below is a program to plot the signal given in (6.19). This example also shows how to
place more than one plot in a figure with the built in MATLAB function subplot.
-2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time - seconds
2
signal unit
-2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time - seconds
The behavior of most of the machines, devices and systems that engineers design is inherently
cyclical, which is usually described using sinusoidal functions. However, it is much more convenient to
work with exponential functions. This is possible through Euler’s identity. Applying (6.17) to (6.19) gives
e j (0t ) e j (0t )
x(t ) A cos(0 t ) A
2 (6.21)
A j j0t A j j0t X j0t X * j0t
e e e e e e
2 2 2 2
where X Ae j is called the phasor of x (t ) . Therefore, x (t ) has been written as the sum of two
complex conjugate exponential functions.
Example 6.7. The following MATLAB statements and table verify (6.21).
Practical periodic signals do not have a simple function representation. However, such signals can be
represented with a series sum of complex exponential functions, called a Fourier series.
This time function will go through two cycles over the time range T0 , and the period of s2 (t ) is given by
2 / (2 0 ) T0 / 2
Although the period of s2 (t ) is T0 / 2 , s2 (t ) also repeats itself every T0 sec, over which it goes through
two cycles. In general we can say that the function of time given by
sk (t ) bk sin(k 0 t )
for k 1, 2, ..., , where bk is the amplitude, repeats itself every T0 / k secs, and over the time range
T0 , sk (t ) goes through k cycles. Similarly, the cosine function given by
ck (t ) ak cos(k 0 t )
for k 1, 2, ..., , where ak is the amplitude, repeats itself every T0 / k secs, and over the time range
T0 , ck (t ) goes through k cycles.
Therefore, if we sum all sine and cosine functions as defined above, we get
x(t ) a0 [a
k 1
k cos(k 0 t ) bk sin(k 0 t )] (6.22)
and then x (t ) will also repeat itself every T0 secs, because for each k the cosine and sine functions go
through an integer number of cycles over the time range T0 secs. Since the average value of the sine
and cosine terms is zero, a0 is included to account for the average value of x (t ) . We say that x (t ) is a
periodic function, since for all t we have
x(t ) x(t T0 )
and x (t ) given (6.22) is called a trigonometric Fourier series. The frequency given by 0 2 / T0 is
called the fundamental frequency of x (t ) . If the Fourier series (sum of sinusoidal functions) is to have
the same period as x (t ) , then all sinusoidal functions in the Fourier series must have frequencies given
by k 0 rad/sec, where k is an integer.
Given any kind of a practical periodic signal x (t ) , we can find the ak and bk coefficients such
that x (t ) can be written as a Fourier series. These coefficients, called the trigonometric Fourier series
coefficients, are found with
T0 T0
2 1
ak
T0 x(t ) cos(k
0
0 t ) dt , a0
T0 x(t ) dt
0
(6.23)
T0
2
bk
T0 x(t ) sin(k
0
0 t ) dt (6.24)
Example 6.8. Let us apply (6.22) to represent the sawtooth wave x (t ) shown in Figure 6.5. The period
x (t)
t - sec
-2 -1 1 2 3
These coefficients are used in the following MATLAB program to evaluate the Fourier series.
1.2
0.8
signal value
0.6
0.4
0.2
-0.2
-1 -0.5 0 0.5 1 1.5 2
time - sec
Figure 6.6a. Reconstructed signal using K=10 terms in the Fourier series.
1.2
0.8
signal value
0.6
0.4
0.2
-0.2
-1 -0.5 0 0.5 1 1.5 2
time - sec
Figure 6.6b. Reconstructed signal using K=100 terms in the Fourier series.
The oscillation about the discontinuity is called Gibbs’ oscillation. The time duration of Gibbs’ oscillation
goes to zero as the number of terms used in the Fourier series increases. However, the amplitude of the
oscillation does not go to zero.
__________
The Fourier series expression for x (t ) can be written in another way. Based on Euler’s identity
we have that
e jk0t e jk0t
cos(k 0 t )
2
and
e jk0t e jk0t
sin(k 0 t )
j2
Therefore, the Fourier series in (6.22) for x (t ) becomes
e jk0t e jk0t e jk0t e jk0t
x(t ) a0 [ak bk ]
k 1 2 j2
ak jbk jk0t ak jbk jk0t
a0
k 1 2
e
k 1 2
e
ak j bk
, k 1, 2, 3,
Xk (6.25)
2
Since according to (6.23), a k ak , and according to (6.24), b k bk , we have
a k j b k a j bk
X k k X k* , k 1, 2, 3, (6.26)
2 2
which becomes
x(t ) Xk
k
e jk0t (6.28)
where the X k , called the complex Fourier series coefficients, are found by substituting (6.23) and (6.24)
into (6.25) to get
T0
Xk 1
x(t ) e jk0t dt (6.29)
T0 0
for k 0, 1, ..., . The Fourier series in (6.28) is called the complex exponential Fourier series.
The idea of writing a time function or signal in terms of a sum of sinusoidal functions is a very
fundamental concept that is widely applied in engineering. In view of (6.25), the X k are in general
complex numbers, which we can write in polar form to get
X k X k e j X k
x(t )
k
X k e j X k e jk t0
x(t ) X 0 2 X k cos(k0t X k ) (6.30)
k 1
This shows that 2 X k gives the amplitude and X k gives the phase of the sinusoidal contribution to
x (t ) at the frequency k0 rad/sec.
Example 6.9. To assess the nature of a signal x (t ) , the amplitude and phase of each sinusoidal function
that contributes to x (t ) is plotted versus the frequency of the sinusoidal function. For the periodic
signal x (t ) given in Example 6.8, (6.29) gives the complex Fourier series coefficients, which results in
0.75
1 1 j ( k 1) /2
Xk
1 0.25
(t 0.25)e jk 2 t dt
2 k
e , k 0
1
, k 0
2
Figure 6.8 shows the amplitudes of the sinusoidal contributions to x (t ) versus the frequency of the
sinusoid. This plot is called the magnitude spectrum.
0.5
0.4
Magnitude
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
frequency index k
The following program uses the complex Fourier series coefficients to plot the magnitude spectrum of
the sawtooth wave.
Program 6.6. Using complex Fourier series coefficients to find and plot the magnitude spectrum.
_____________
In this section we saw how convenient it is in MATLAB to use complex exponential functions for
representing a periodic signal. In several of the following chapters this approach to signal
representation will be extended to include aperiodic continuous time signals, discrete time periodic
signals and aperiodic discrete time signals.
6.6 Complex Impedance
The complex exponential function also plays an important role in linear system analysis and design. To
see how readily MATLAB can be involved in this, Euler’s identity will be applied to AC circuit analysis.
Then, with MATLAB we will analyze circuits for the sinusoidal response to sinusoidal inputs. Before we
proceed, let us consider the electrical devices used to build circuits. Figure 6.9 shows the passive
components: resistor, capacitor and inductor.
Figure 6.9. Passive electrical circuit components: R, L and C and current and voltage references.
di (t )
v(t ) L (6.31)
dt
Suppose the current is some sinusoidal function, i (t ) A cos(t ) . Then, the phasor I for the
current is given by
I Ae j
V A L e j ( /2) j L Ae j
With the voltage and current phasors we have
V j L I Z L I (6.32)
The term Z L j L , which relates the inductor current phasor to the inductor voltage phasor is called
the impedance of an inductor. If we use instead the current-voltage relationship given by
1
L
i (t ) v(t ) dt
then we get the phasor relationship given by
1 1
I V V (6.33)
j L ZL
For AC circuit analysis, we have changed the time-domain derivative relationship between the inductor
voltage and inductor current into a frequency-domain algebraic relationship between the inductor
voltage phasor and the inductor current phasor.
Suppose the voltage is some sinusoidal function, v (t ) A cos(t ) . Then, the phasor V for the
voltage is given by
V Ae j
I jC V (6.35)
and
1
V I ZC I (6.36)
jC
The term Z C 1/ jC , which relates the capacitor current phasor to the capacitor voltage phasor, is
called the impedance of the capacitor.
In (6.32), (6.36) and (6.37) we see that multiplying a current phasor by an impedance produces a
voltage phasor. These equations show that if we are only interested to solve the integral-differential
equations that result from applying Kirchhoff’s laws to linear circuits for the steady-state response to
sinusoidal inputs, then we can immediately convert these equations to complex algebraic equations in
terms of current phasors, voltage phasors and impedances.
AC circuit analysis is concerned with finding the steady-state sinusoidal response of a linear circuit to a
sinusoidal input. Since MATLAB can work with the complex data type, applying MATLAB to AC circuit
analysis is similar to applying MATLAB to resistive circuit analysis.
As a general example, consider the RLC circuit shown in Figure 6.10, where the input is the
voltage given by
vs (t ) A cos(t )
The amplitude A and phase determine the phasor Vs of vs (t ) , and the frequency will be
assigned values over a range to see how the circuit responds differently, depending on the frequency of
the input.
C L
To find the steady-state sinusoidal current, let us do a mesh analysis of the circuit, and apply
Kirchhoff’s voltage law. Summing the voltage drops around the mesh gives
1 di(t )
vs (t )
C i (t ) dt L
dt
R i (t ) 0 (6.38)
1 1 1 1 * jt
(Vs e jt Vs*e jt ) ( Ie jt I e )
2 2C j j
L R
( j Ie jt j I *e jt ) ( Ie jt I *e jt ) 0
2 2
Rearranging this equation gives
1 1
(Vs I j LI RI ) e jt (Vs I j LI RI )* e jt 0
jC jC
1
Vs I j LI RI 0 (6.39)
jC
The time domain sum of voltage drops in (6.38) have been replaced by the sum of phasor voltage drops
in (6.39) resulting in an algebraic equation for the current phasor giving
1
Vs ( j L R ) I Z ( j ) I (6.40)
jC
or
1 jC
I Vs Vs Y ( j ) Vs
1
j L R 1 LC j RC
2
jC
Notice that when 2 1/ ( LC ) , then I Vs / R , as if the capacitor and inductor are equivalent to an
ideal conductor. If we plot Y ( j ) and Y ( j ) versus we see how the circuit modifies the
amplitude and phase of the input voltage vs (t ) to obtain the amplitude and phase of the current i (t ) .
j RC
V RI Vs H ( j ) Vs (6.41)
1 LC 2 j RC
Example 6.9. With the complex arithmetic capability of MATLAB we can easily assess the performance
of the circuit given in Figure 6.10 for different values of the circuit components. Let R 33 ,
L 10 mH and C 0.11 F . The following MATLAB program finds H ( j ) , and plots the magnitude.
We see in Figure 6.11 that H ( j ) has the characteristic of a band-pass filter.
0.9
0.8
0.7
e
0.6
gn d
itu
0.5
Hma
0.4
0.3
0.2
0.1
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Hz 4
x 10
Example 6.10. Let us apply the complex impedance concept to the circuit given in Figure 6.12, and find
the response v (t ) to the input vs (t ) .
L1 L2
where f1 0.2 Hz and f 2 2 Hz. The input is shown in Figure 6.13. This input was plotted with the
following program.
clear all; clc;
f1=0.2; w1=2*pi*f1; f2=2.0; w2=2*pi*f2;
T_total=2/f1; % specify total time
N=5001;
t=linspace(0,T_total,N);
vs=2*cos(w1*t-pi/4)+3*cos(w2*t-pi/6);
plot(t,vs)
grid on
xlabel('time - sec')
ylabel('input')
Program 6.8. Find and plot the input .
5
input
-5
0 1 2 3 4 5 6 7 8 9 10
time - sec
Now we will replace each circuit component by its impedance and each sinusoidal current and
sinusoidal voltage by its phasor resulting in the frequency domain circuit shown in Figure 6.14. Since the
given circuit is a linear system, we can find the steady-state response to vs (t ) by finding the response to
each sinusoidal component in vs (t ) and then sum these responses.
jwL 1 jwL 2
1 I2
Vs I1 R V
jwC
In the frequency domain, the Kirchhoff voltage law (KVL) equations for the circuit meshes are
given by
1
Vs j L1 I1 ( I1 I 2 ) 0 (6.42)
jC
1
( I 2 I1 ) j L2 I 2 RI 2 0 (6.43)
jC
We must solve (6.42) and (6.43) with 1 to find the phasor I 2 , and then the contribution to v (t )
due to the first component in vs (t ) can be found, and then again with 2 to find the contribution
to v (t ) due to the second component in vs (t ) . This is done by the following MATLAB program, and the
result is shown in Figure 6.15, where we see that the high frequency component of vs (t ) has been
significantly attenuated (filtered) by the circuit.
% AC analysis of third order Butterworth filter
%
L1=3/2; L2=1/2; C=4/3; R=1; % specify circuit component values
f1=0.2; f2=2.0; % frequencies of components of the input signal
w=2*pi*[f1 f2];
Vs=[2*exp(-j*pi/4) 3*exp(-j*pi/6)]; % phasors of the two input components
T_total=2/f1; N=1001; % plot output over 2 cyles of the first input component
t=linspace(0,T_total,N);
v=zeros(1,N); % initialize the output voltage vector to zero
for k=1:2 % analyze the circuit for each input component frequency
% find impedances
ZL1=j*w(k)*L1;
ZL2=j*w(k)*L2;
ZC=1/(j*w(k)*C);
Z=[ZL1+ZC -ZC; ... % set up the impedance matrix Z
-ZC ZC+ZL2+R];
V=[Vs(k) 0]'; % mesh voltage vector
Y=inv(Z); % invert the impedance matrix
I=Y*V; % solve for the mesh current phasor vector
% I(2) is the phasor of the current in mesh 2 for the frequency w(k)
V(k)=R*I(2); % phasor of output component
v=v+abs(V(k))*cos(w(k)*t+angle(V(k))); % contribution to output
end
plot(t,v)
grid on
xlabel('t - sec')
ylabel('output voltage')
0.5
output voltage
-0.5
-1
0 1 2 3 4 5 6 7 8 9 10
t - sec
Figure 6.15. Output of the low-pass filter.
___________