ECE 459
COMMUNICATIONS I
Information Sheet
Fall 2015
Instructor: Prof. Juan Alvarez, 3046 ECEB, [email protected]
Teaching Assistant: Cheng Chen, [email protected]
Lectures: Tuesdays and Thursdays 9.30-10:50 a.m., 4
M-Files
M-les allow you to save multiple MATLAB commands in a le and then run them
with a single command or mouse click. While you may have solved the simple problem above correctly on the rst try, mo
Changes you make to the current directory and path are not saved from one
MATLAB session to the next. At the end of the Script M-les section below,
we describe how to change these and other items aut
Chapter 3
Interacting with MATLAB
In this chapter we describe an effective procedure for working with MATLAB, and for
preparing and presenting the results of a MATLAB session. In particular we discuss
The result appears in Figure 2.6. Note that we used a semicolon to suppress printing
of the 301-element vector X.
4
3.5
3
2.5
2
1.5
1
0.5
0
1
0.5
0
0.5
1
1.5
2
Figure 2.6. Plot of a Parabola.
We descr
The term folder is now more common than directory; for a computer le
system, they mean the same thing. We will use directory because MATLAB
uses this term in its documentation. However, its interface
While the Desktop provides some new features and a common interface for
the Windows and UNIX versions of MATLAB, it may also run more slowly
than the basic Command Window interface, especially on old
Chapter 2. MATLAB Basics
24
is that doing so via MATLAB commands in the Command Window provides more
robustness, especially if you want to save your commands in an M-le (see Chapter 3)
in order to rep
Figure 2.2. Desktop with the Workspace Browser.
You can make very general assignments for symbolic variables and then manipulate them:
> syms x y
> z = x2 - 2*x*y + y
z =
x2-2*x*y+y
> 5*y*z
ans =
5*y*
function y = sinelimit(c)
% SINELIMIT computes sin(x)/x for x = 10(-b),
% where b = 1, ., c.
format long
b = 1:c;
x = 10.(-b);
y = (sin(x)./x);
The rst line of the le starts with function, which ident
to task1.m rst; otherwise, MATLAB will not recognize them.
Any variables that are set by running a script M-le will persist exactly as if
you had typed them into the Command Window directly. For examp
For M-books to run properly, you must enable execution of the necessary
macros in Word. The safest way to do this is to see whether you get a
security warning dialog box when you open an M-book and,
Several Sine Curves
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
0
1
2
3
4
5
6
7
Figure 3.1. Sine Curves.
mands, and graphics. This allows you more control over formatting than publish.
A simple rst approach
%
% These values illustrate the fact that the limit of
% sin(x)/x as x approaches 0 is equal to 1.
If your M-le puts two successive gures in the same gure window, then only
the last gure will be writt
to print the gure every time you run a script, you should not include a bare print
command in an M-le. Instead, you should use a form of print that sends the output
to a le. It is also helpful to give
waits until the user presses a key before proceeding. Of course, if the recipient of your
M-le is not familiar with pause, then you should include appropriate guidance at
such points; for example, wit
0.99999999833333
0.99999999998333
None of the values of b from 1 to 5 yields the desired answer, 1, to 15 digits. Judging
from the output, you can expect to nd the answer to the question we posed abov
You can greatly enhance the readability of your M-le by including frequent
comments. Your comments should explain what is being calculated, so the
reader can understand your procedures and strategies
at the beginning of a script M-le that creates graphics, to close all gure windows
and start with a clean slate.
As mentioned above, the commands in a script M-le will not automatically be
displayed i
2
x +x+1
7
6
5
4
3
2
1
2
1.5
1
0.5
0
x
0.5
1
1.5
2
Figure 2.4. The Parabola y = x2 + x + 1 on the Interval [2, 2].
Modifying Graphs
You can modify a graph in a number of ways. You can change the title
exp(x) and sin(x)
1
0.5
0
0.5
1
0
2
4
6
8
10
x
Figure 2.3. Two Intersecting Curves.
Graphics
In this section, we introduce MATLABs two basic plotting commands and show how
to use them.
Graphing with e
ans =
7+4*2(1/2)
The second solution can be extracted with x(2) and y(2).
Note that, in the preceding solve command, we assigned the output to the vector
[x, y]. If you use solve on a system of equati
in the expression. This is done by using the subs command. For example, presuming
that the symbol expression w is dened and it involves the symbolic variable u, then
the command subs(w, u, 2) will sub
Recovering from Problems
Inevitably, when using any mathematical software system, you are bound to encounter
minor glitches. Even while entering simple arithmetic commands, you may accidentally mistyp
You can also use the Help Navigator to locate the documentation that you will
explore in the display pane. The Help Navigator has four tabs that allow you to
arrange your search for documentation in d
Figure 1.2. The MATLAB Desktop with Several Commands Evaluated.
scroll by. You can use the scroll bar on the right of the window to scroll back up.
Alternatively, you can force MATLAB to display infor
Figure 1.1. A MATLAB Desktop.
MATLAB 6 has a Desktop, but in older versions of MATLAB, for example
5.3, there was no integrated Desktop. Only the Command Window appeared
when you launched the applicat
Chapter 2
MATLAB Basics
In this chapter, you will start learning how to use MATLAB to do mathematics. We
recommend that you read this chapter while running MATLAB. Try the commands as
you go along. Fe
describe a MATLAB feature that is available only in the Professional Version, we
highlight that fact clearly.
Installation
If you intend to run MATLAB, especially the Student Version, on your own comp
MATLAB Windows
We have already described the MATLAB Command Window and the Help Browser,
and have mentioned in passing the Command History Window, the Current Directory
Browser, and the Workspace Brow