fd

No Title

EECS20: Introduction to Real-Time Digital Systems

Lab01: Introduction to Matlab


EECS20: Introduction to Real-Time Digital Systems
©1996 Regents of the University of California.
By K. H. Chiang, William T. Huang, Brian L. Evans.
The last three exercises are copied from Labs for Signals and Systems by Virginia Stonick and Kevin Bradley. URL: http://www-inst.eecs.berkeley.edu/~ee20
News: ucb.class.ee20
Assigned: 29 Jan 97, Checkoff: 5 Feb 97, Writeup Due: 7 Feb 97

Matlab

Half of the laboratory assignments will use Matlab. Matlab stands for ``Matrix Laboratory'' and is a general-purpose programming language. Matlab interprets commands like Lisp does, instead of compiling source code like C and Fortran require. Matlab, unlike Lisp, has an extensive sets of routines, or toolboxes, that perform matrix, signal processing, image processing, controls, optimization, and statistics computations.

By building your own expertise in Matlab, you will be able to attack numerical problems in engineering quickly by using its high-powered routines and by avoiding the compile-link-debug cycle in C and Fortran.gif Since Matlab is available on a variety of different platforms, your Matlab scripts can run without modification on several different kinds of computers.

Here are a few key points to keep in mind when you're using Matlab:

Other technical tips are available from Matlab's creators at
http://www.mathworks.com/technical.html#general.

In addition, you can have further fun by running the Matlab demo:

>> demo
Enjoy the pretty pictures. Drive those Pentiums into the ground.

Questions

  1. Familiarize yourself with Matlab on the PC. UC Berkeley has a site license to run Matlab on all Unix workstations, so all machines in instructional clusters have access to Matlab. This assumes that you have an account on the instructional machines though. [If you don't have an account, you can get one by following the instructions posted on bulletin boards around 105 Cory. All students taking EECS courses are entitled to such an account.]
  2. Familiarize yourself with Chapters 1-3, 5, 7, and 8 in Mastering Matlab, as you will be applying the concepts and language constructs therein. Note also that this course will not be an exercise in who can memorize what Matlab function. Instead, you should try to use existing Matlab commands when possible so as to get in the habit of reusing existing code instead of writing your own. Code reuse is a fundamental concept in software engineering, and will prevent you from reinventing and debugging the wheel repeatedly, when you could be building a Lamborghini instead [well, maybe a Dodge Dart].
  3. Make use of comments with the % sign [so that you can figure out what you did when you look at your code at a future date]. Use help and lookfor when necessary.
  4. Define a sine wave with frequency 10 Hz and zero phase over the time interval from to at increments of . Call this signal . Then, plot the signal over the same time interval, making sure that the axes are correctly labeled. Is this a continuous function?
  5. Next, define a new signal that is the signal multiplied by a decaying exponential term . Form and plot the sum and product of and on the same interval with the same increment.
  6. Write a Matlab function that finds and replaces all negative entries in a matrix with zeros.
  7. Write a Matlab function half that removes every other element from an arbitrary length vetor, creating a shorter vector made of only the odd-numbered elements of the original vector. Use only matrix and vector manipulations; do not use loops.
  8. Write a Matlab function double that creates a longer vector by adding an additional element, 0, between neighboring elements in the original vector. Then replace each of these new 0 elements with the average of its neighboring elements. Use only matrix and vector manipulations; do not use loops.
  9. What happens to a vector in half(double(x)) and double(half(x))?

find and replace

elementwise

colon operator

matrix multiplication

argument error [trig functions] dimension error

transposition


khc
Sun Feb 4 13:30:03 PST 1996