Lab 1
[PDF]
ECE 201: Introduction to Electrical Engineering II
Prof. B.-P. Paris
Lab 1: Introduction to MATLAB
Solve the MATLAB problems below. To generate a report of your work start a
diary file called LAB1 by typing diary at the command prompt. All your
MATLAB commands as well as the answers you get will be captured in the diary
file.
- Clear the memory. Make sure that no current variables exist.
- Generate a row vector A whose first element is 4 and second element is
7.
- Generate column vector B by transposing row vector A. What is the
size of B?
- Generate a column vector of 12 zeros and call it C.
- Generate a 12x12 matrix of ones and call this matrix D.
- Replace the 30th element in D with a 9. On which row and which column
does the 9 appaear in D; explain.
- Replace the element located at the 5th row and 4th column in D with
a 4.
- Replace the first column in D with C. Does the number of rows change?
- Generate a row vector E that starts with the value 2, ends at 40 and
has an increment between elements of 2. How many elements are in E?
- Generate a vector F from the last 14 elements in E. What does the 3rd
element of F equal? Make a 12x12 matrix called G by replacing the 3rd
column of D with the column vector C.
- Does any element in G equal 9? If yes, what is its location?
- Generate a row vector that runs sequentially from 13 to 2. (Hint:
Increment = -1.)
- List the directory of variables currently in memory. How many total
bytes are used?
- How many total variables have been generated?
Stop the diary facility. Using a word processor, open the diary file LAB1, clean
up any errors or text you don’t want displayed, annotate your work, then print off
a copy and turn in no later than one week after you did this lab. Don’t forget to
add your name, your section number, and the date to the top of LAB1A when you
are inside the word processor.