Lab Task 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

National Skills University

Islamabad

NAME: MUHAMMAD HAMZA

ID: F22BSCIET031

INSTRUCTOR: SIR SHAHROZ

DEPARTMENT: IET

COURSE: SIGNAL AND SYSTEM


LAB#01

Introduction to MATLAB

Task#01
Create vectors:

a. ‘A’ of even whole numbers between 19 and 63.

b. ‘B’ of odd whole numbers between 66 and 120.

Part A

Part B
Task#02
Let x = [3 -2 0 5 1 9 5 6]

a. Add 5 to each element of this vector.

b. Multiply the even indexed elements with 4.

c. Compute the square root of each element.

d. Compute the cube of each element.

Part A

Part B
Part (C+D)

Task#03
Let x = [4 3 9 1] and y = [2 1 9 -3]

a. Add the sum of the elements of x to y

b. Raise each element of y to the power specified by the corresponding element of x.

c. Multiply each element in x by the corresponding element in y and store the result in ‘c’.

d. Evaluate y*x’ and interpret the result.

Part A
Part B

Part C

Part D
Task#04
Given a vector t = [-3:0.2:2] write down the MATLAB expressions that will correctly compute
the following:

a. ln (1 − 𝑡 + 𝑡^3 ) b. [1 + sin (3 ∗ 𝑡 2 )] c. cos (𝑡)^2 + sin (2 ∗ 𝑡)^ −3


Part A

Part B
Part C
Task#05
Find a short MATLAB expression to build to matrix that is given in question

Task#06
Give a MATLAB expression that uses only a single matrix multiplication with Matrix B (obtained in
problem 5) to obtain:

a. The difference of columns 2 and 3 of Matrix B

b. The last row of B

c. A version of B with rows 2 and 3 swapped.

Part A
Part B

Part C
Task#07
Given a matrix A, such that: Perform the following operations:

a. Extract the 3rd column of matrix A and store it in vector B.

b. Extract the 1st and 3rd columns of matrix A and store them in matrix C.

c. Add the 1st and 3rd rows of matrix A together and store the result in vector D.

d. Change the value in the 2nd row and 3rd column of A to +7 (instead of -7) and call the result AA (do
not destroy/change the original A matrix).

e. Create a matrix that contains rows 1 and 3 from A, the second row of AA, and the result of part (c).

Part A

Part B
Part C

Part D
Part E

You might also like