Page 22 - Numerical Analysis Using MATLAB and Excel
P. 22
Using MATLAB to Make Plots
We can also express the numerator and denominator of this rational function as a combination of
linear and quadratic factors. We recall that in a quadratic equation of the form
2
x + bx + c = 0 whose roots are x 1 and x 2 , the negative sum of the roots is equal to the coef-
ficient of the term, that is, ( x + x ) – 2 = b , while the product of the roots is equal to the
x
b
1
b
c
constant term , that is, x ⋅ x = c . Accordingly, we form the coefficient by addition of the
2
1
complex conjugate roots and this is done by inspection; then we multiply the complex conjugate
roots to obtain the constant term using MATLAB as indicated below.
c
(2.4186+1.0712i)*(2.4186 −1.0712i) % Form the product of the 1st set of complex conjugates
ans = 6.9971
(−0.3370+0.9961i)*(−0.3370−0.9961i) % Form the product of the 2nd set of complex conjugates
ans = 1.1058
(1.6760+0.4922i)*(1.6760−0.4922i)
ans = 3.0512
(−0.2108+0.9870i)*(−0.2108−0.9870i)
ans = 1.0186
1.6 Using MATLAB to Make Plots
Quite often, we want to plot a set of ordered pairs. This is a very easy task with the MATLAB
y
y
plot(x,y) command which plots versus . Here, is the horizontal axis (abscissa) and is the
x
x
vertical axis (ordinate).
Example 1.10
ω
Consider the electric circuit of Figure 1.1, where the radian frequency (radians/second) of the
applied voltage was varied from 300 to 3000 in steps of 100 radians/second, while the amplitude
was held constant. The ammeter readings were then recorded for each frequency. The magnitude
⁄
of the impedance Z was computed as Z = V A and the data were tabulated in Table 1.1.
ω
Plot the magnitude of the impedance, that is, Z versus radian frequency .
Solution:
ω
We cannot type (omega) in the MATLAB command window, so we will use the English letter
w instead.
Numerical Analysis Using MATLAB® and Excel®, Third Edition 1−9
Copyright © Orchard Publications