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

Department of Electrical Engineering

Semester: 6th Subject: Signals and Systems Lab. No. 01


Objective:
Verify the properties of convolution using the given signals.

Apparatus:
Personal Computer, MATLAB
Procedure:
Task 1: Calculate the area of a circle of radius 15 in Matlab.
Code:
r=15
Area=2*pi*r^2

Output
Area =

1.4137e+03

Task 2 Calculate inverse of a matrix [3x3] matrix A using Matlab and confirm your answer
using Matlab built-in inv() command.

Code:
Department of Electrical Engineering
clc
clear all
close all

A=[10 23 54 ; 65 23 43 ; 23 98 45]

inv(A)

OUTPUT:

A=

10 23 54
65 23 43
23 98 45

ans =

-0.0133 0.0178 -0.0011


-0.0081 -0.0033 0.0129
0.0244 -0.0019 -0.0053
Department of Electrical Engineering

TASK 3: 4. Open help windows by typing doc command in the Command Window, and find
out the functions of the following commands;

Output:

a. Real: This MATLAB function returns the real part of each element in array Z

b. Conj: This MATLAB function returns the complex conjugate of each element
in Z.
c. Rand: This MATLAB function returns a single uniformly distributed random
number in the interval (0,1).
d. Cat: Concatenate arrays C = cat(dim,A,B) C = cat(dim,A1,A2,…,An
e. Factor: This MATLAB function returns a row vector containing the prime
factors of n.
Eye: Identity matrix I = eye ,I = eye(n)
f. Zeros: Create array of all zeros
Ones: Create array of all ones . This MATLAB function returns the scalar 1
g. Diag Create diagonal matrix or get diagonal elements of matrix
tic, toc: toc - Read elapsed time from stopwatch tic - Start stopwatch timer

TASK: 5.Enter two matrices of [3x3] size, and find the product of the two matrices, also find the
element-wise product of the matrices.
CODE:
clc
close all
clear all

A=[12 34 23;54 56 87;23 54 63]


B=[45 23 13;45 56 43;23 45 23]
A.*B
x=A*B

output:

A=

12 34 23
54 56 87
23 54 63
Department of Electrical Engineering

B=

45 23 13
45 56 43
23 45 23

ans =

540 782 299


2430 3136 3741
529 2430 1449

x=

2599 3215 2147


6951 8293 5111
4914 6388 4070

>>

TASK: 6. Generate two 100 sampled random data points using rand () function i.e.
rand(1,100). Add the two vectors together using simple vector add ition. Determine the time
required for addition using tic, toc pair function. [Hint: you may use Matlab help for the usage of
these functions].

CODE:
clc
close all
clear all
tic
A=rand(1,100)
B=rand(1,100)

c=A+B
toc

OUTPUT:
Department of Electrical Engineering

TASK: Write a program in Matlab to get 10 numbers from user and generate the square of
those numbers

CODE:

clc
clear all
close all
x=input('Enter 10 numbers [x x x]\n')

j=x*2

OUTPUT:

Enter 10 numbers [x x x]
[1 2 3 4 5 6 7 8 9 2]

x=

1 2 3 4 5 6 7 8 9 2

j=
Department of Electrical Engineering

2 4 6 8 10 12 14 16 18 4

>>

Conclusion

From this lab we learn the basics of matlab and how to multiply, add of matrices and use
of different commands.

Checked and verified by


Lab Prepared By: Name Aizaz ullah, Sarfraz Ahmed ,Ajmal khan
(Lab Instructor)

You might also like