Open Elective “MATLAB”
(MATLAB Assignments for Laboratory)
Exercise 1.
Create a vector using linspace command with values ranging from 0 to 20 and having 8
elements
Exercise 2. Create the following matrices:
(i) Identity Matrix of order 4
(ii) Magic Matrix
(iii) Matrix with all zeros
Exercise 3. (i) Find a short MATLAB expression to build the matrix
1234 5 6 7
(9 5 7 5 8 2 1)
2 4 6 8 10 12 14
(ii) After building this matrix reshape this matrix in 1 x N shape where N is the total number of
elements in the given matrix.
(iii) Access only 2nd ,3rd rows and 2nd to 5th columns from the given matrix.
(iv) Delete the 4th column from the given matrix.
Exercise 4. Give a MATLAB expression that multiplies two vectors to obtain
000
(1 1 1)
222
Exercise 5. Create a vector of 7 elements using a short MATLAB expression.
Exercise 6. Find the addition and multiplication of the matrix
A=
234
(2 1 2)
343
B=
123
(4 1 2)
349
Exercise 7. Find the rank and trace of matrix
146
A= (4 9 2)
367
Exercise 8. Find the inverse of matrix
023
A= (4 0 2)
900
Exercise 9.
Find the Diagonal of the matrix
5 2−3
(−4 9 2)
9 6−9
Exercise 10.
Find the Eigen values and Eigen vector of the matrix
321
(1 0 2)
320
Exercise 11.
Create a random matrix of size 4X4 with normalized values.
Exercise 12.
Create a cell-array.
Exercise 13.
Write command for any 5 built-in functions.
Exercise 14.
Define a user-defined function and plot its graph.
Exercise 15.
Use the colon operator to create a vector of x values ranging from zero to pi, compute the
cosine of these values, and plot the result.
Exercise 16.
Plot Sinc function, where Sinc (x) = xsin(x) , and -π ≤ x ≤ 2π
Exercise 17.
Write a script to show the use of
a) if else end statement
b) while loop
Exercise 18.
Exchange the real and imaginary parts of the following matrix
A= 0.8147 + 0.1576i 0.9058 + 0.9706i 0.1270 +
0.9572i
0.9134 + 0.4854i 0.6324 + 0.8003i 0.0975 + 0.1419i
Exercise 19.
If x=[1 5 9 13; 2 7 4 9; 1 4 8 15], then
a) display the last element by using disp command.
b) display the sum of each row as shown below
The sum of 2nd row =
The sum of 3rd row =
Exercise 20.
Plot sin(x) and cos(x) on the same figure using different colors.