Anda di halaman 1dari 3

Matlab Introduction | Page 1

Laboratory 1: Cover Sheet

Name __________________________________________ R.No. __________________ Date ___________________ Section _______________

Laboratory Objectives:
To understand Matlab environment Familiarization with the basic MATLAB features - notations and operations Use expressions to compute new variables Perform basic operations on matrix

Place a check mark in the Assigned column next to the exercises your instructor has assigned to you. Attach this cover sheet to the front of the packet of materials you submit following the laboratory. Activities Prelab Exercises In-lab Exercises Take Home Exercises Any Other Remarks Signature

Matlab Introduction | Page 2

Theory
The best way for you to get started with MATLAB is to learn how to handle matrices. This section shows you how to do that. In MATLAB, a matrix is a rectangular array of numbers. Special meaning is sometimes attached to 1-by-1 matrices, which are scalars, and to matrices with only one row or column, which are vectors. MATLAB has other ways of storing both numeric and nonnumeric data, but in the beginning, it is usually best to think of everything as a matrix. The operations in MATLAB are designed to be as natural as possible. Where other programming languages work with numbers one at a time, MATLAB allows you to work with entire matrices quickly and easily. MATLAB was written originally to allow mathematicians, scientists, and engineers to handle the mechanics of linear algebra that is, vectors and matrices as effortlessly as possible. In this section we introduce these concepts.

Vectors
A vector is an ordered list of numbers. You can enter a vector of any length in MATLAB by typing a list of numbers, separated by commas or spaces, inside square brackets. For example,
>> Z = [2,4,6,8]

Z = 2 4 6 8
>> X = 1:9 X = 1 2 3 4 5 6 7 8 9

Matrices
A matrix is a rectangular array of numbers. Row and column vectors, which we discussed above, are examples of matrices. Consider the 3 4 matrix It can be entered in MATLAB with the command:
>> A = [1, A = 1 2 5 6 9 10 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12] 3 4 7 8 11 12

Matlab Introduction | Page 3

Observations

program
1. g = [1 2 3] 2. size(g) 1. A = [1+j*2 1-j*7] 2. A 3. A. 1. G = [1 2 3;4 5 6;7 8 9]

Output

Do It Yourself
1. Consider the Matrices

2 S= 7j

2j T= 3

-5 -j
iii) S-1.T iv) Tt.S-1

1+2j 3

a. Generate S and T in Matlab b. Calculate i) S.T ii) T.S

2. Consider the Matrices created in observations a. b. c. d. e. Perform g*g g*g g.*g G*g G(1:2,1:2)

3. Generate a 4x4 matrix P, whose first column is an array of 0, 2, 4 and 6; second column is an array of 1, 3, 5, and 7; third is the second column in reverse order and fourth column is the first column in reverse order. 4. Generate using the commands discussed above; i) innermost 2x2 submatrix of P ii) top rightmost 3x3 submatrix of P iii) bottom leftmost 2x2 submatrix of P 5. Create a 5x5 matrix T such that: [T] k, l = k - l Compute transpose of this matrix