Eee 185
Eee 185
Course Grading
Midterm I : 20%
Midterm II: 20 %
Final Exam: 40 % (comprehensive)
Homework: 20% (every two weeks)
02/25/25 Midterm I
PC based MATLAB can be opened by clicking on the MATLAB icon. The MATLAB prompt is
>>, which indicates that commands can be started, either line by line, or by running a stored
(a) Open a file in any text editor ( either in MATLAB or Word/Notepad/Wordpad), and write
the program.
(c) To run the program, click on the Run arrow, or type the filename after the prompt:
>> filename
The program will run, and the results/error messages, if any, will be displayed on the screen.
I. NUMBERS
Generation of numbers
>> z1 = 3
>> z2 = 4
>> z1 = 3+4j
>> z2 = 4+5j
Note: The symbol i can be used instead of j to represent √-1.
Example: Find the magnitude and phase of the complex number 3+j*4
>> z = 3+j*4
>> z = z1 + z2 ; addition
>> z = z1 - z2 ; subtraction
II. VECTORS
Generation of vectors
>> z = x+ y ; addition
>> z = x - y ; subtraction
>> z = x. * y ; multiplication
>> z = x. / y ; division
Note: The dot after x is necessary since x is a vector and not a number.
MATLAB TOOLBOXES
MATLAB commands are divided into different toolboxes depending on the applications.
Communication Toolbox
Image Processing Toolbox
Signal Processing Toolbox
Controls Toolbox
Spline Toolbox
Neural Network Toolbox
Nonlinear Control Design Toolbox
Statistics Toolbox
Optimization Toolbox
Symbolic Math Toolbox
Partial Differential Equation Toolbox
PROGRAMMING WITH VECTORS
Programs involving vectors can be written using either FOR LOOPS or VECTOR commands.
Since MATLAB is basically a vector based program, it is often more efficient to write programs
using VECTOR commands. However, FOR LOOPS give a clearer understanding of the
S = 1 + 3 + 5 . . . . . . .99.
FOR LOOP approach
S = S + i;
end;
Example: Generate the discrete-time signal y(n) = n sin(n/2) in the interval 0 n 10.
n1 = n – 1;
y(n) = n1 * sin(pi*n1/2);
end;
>> y ; gives the vector y
VECTOR approach
>> n = 0 : 10; ; creates the vector n
After logging into MATLAB, you will receive the prompt >>. In order to open up SIMULINK,
>> simulink
Two windows will open up: the model window and the library window. The model window
is the space utilized for creating your simulation model. In order to create the model of the
system, components will have to be taken from the library using the computer mouse, and
If you browse the library window, the following sections will be seen. Each section can be
Sources - This section consists of different signal sources such as sinusoidal, triangular,
Sinks - This section consists of measuring instruments such as scopes and displays
Linear - This section consists linear components performing operations like summing,
integration, product.
Communications
DSP
Neural Nets
Simulation Extras
EDITING, RUNNING AND SAVING SIMULINK FILES
The complete system is created in the model window by utilizing components from the various
available libraries. Once a complete model is created, save the model into a file. Click on
Simulation and select Run. The simulation will run, and the output plots can be displayed by
clicking on the appropriate sinks. Save the output plots also into files. The model and output
DEMO FILES
Try out the demo files, both in the main library window, and in the Toolboxes window. There
are several illustrative demonstration files in the areas if signal processing, image processing
and communications.
Continuous-time system
Time scope
Analog signal
x(t) = A sin(t)
+
Time scope
Pseudo-random noise
n(t)
Time scope
Run the simulation for sinusoidal signal, x (t), amplitude of 5 Volts and frequency = 10 rad./s.
The signal n(t) is a pseudo-random noise with maximum amplitude of 0.5 volts.
Observe the combined signal on the time scope, and familiarize yourself with the settings.
(b) Try changing the sinusoidal signal amplitude (2V, 10V), and frequency (20 rad./s, 50
Discrete-time system
x(n) y(n)
+
2
z/(z +z-0.3)
0.4 z-1
(a) Observe the output signal on the time scope, for an input periodic pulse generator having the
following parameters: Pulse amplitude 1 V, Pulse period 2 seconds and pulse width of 1 second.
(b) Try changing the input signal amplitude (2 V, 3V) and pulse width (0.5, 1.5 sec.), and