Page 47 - Numerical Analysis Using MATLAB and Excel
P. 47
Chapter 1 Introduction to MATLAB
• Rational Polynomials are those which can be expressed in ratio form, that is, as
n –
2
n
n –
1
+
b
b
x
b x +
b
… +
+
b x +
x
n
1
1
0
2
--------------------- =
Rx() = Num x() -------------------------------------------------------------------------------------------------------------------------
n –
n –
Den x() a x + a m – 1 x m – 1 + a m – 2 x m – 2 + … + a x + a 0
m
m
1
where some of the terms in the numerator and/or denominator may be zero. Normally, we
express the numerator and denominator of a rational function as a combination of linear and
quadratic factors.
• We use the MATLAB command plot(x,y) to make two−dimensional plots. This command
plots versus where x is the horizontal axis (abscissa), and y is the vertical axis (ordinate).y x
• If a statement, or a row vector is too long to fit in one line, it can be continued to the next line
by typing three or more periods, then pressing <enter> to start a new line, and continue to
enter data.
• We can make a two−dimensional plot more presentable with the commands grid, box,
title(‘string’), xlabel(‘string’), and ylabel(‘string’). For a three−dimensional plot, we can also
use the zlabel(‘string’) command.
x
•The semilogx(x,y) command is similar to the plot(x,y) command, except that the −axis is
represented as a log scale, and the −axis as a linear scale. Likewise, the semilogy(x,y) com-
y
y
mand is similar to the plot(x,y) command, except that the −axis is represented as a log scale,
x
and the −axis as a linear scale. The loglog(x,y) command uses logarithmic scales for both
axes.
• The function log(x) in MATLAB is the natural logarithm, whereas the common logarithm is
expressed as log10(x). Likewise, the logarithm to the base 2 is expressed as log2(x).
• The ratio of any two values of the same quantity, typically power, is normally expressed in deci-
bels (dB) and by definition,
P
dB = 10log ----------
out
P in
• The command gtext(‘string’) switches to the current Figure Window, and displays a cross−hair
which can be moved around with the mouse. The command text(x,y,’string’) is similar to
gtext(‘string’); it places a label on a plot in some specific location specified by x and y, and
string is the label which we want to place at that location.
•The command linspace(first_value, last_value, number_of_values) specifies the number of
data points but not the increments between data points. An alternate command uses the colon
notation and has the format x=first: increment: last. This format specifies the increments
between points but not the number of data points.
1−34 Numerical Analysis Using MATLAB® and Excel®, Third Edition
Copyright © Orchard Publications