Lab 2 Ss
Lab 2 Ss
Lab 2 Ss
LAB # 02
Spring 2018
“On my honor, as student of University of Engineering and Technology, I have neither given
nor received unauthorized assistance on this academic work.”
Submitted to:
Miss Dur-e-Nayab
7 March 2018
TASK 01
Write a program to generate a new matrix B from the matrix A given below such that each
column in the new matrix except the first one is the result of subtraction of that column from
the previous one i.e. 2nd new column is the result of subtraction of 2nd column and 1st column
and so on. Copy the first column as it is in the new matrix.
13 6 9
A= 148
2 8 17
TASK 02
Generate two 2500 sampled random discrete time signals (1 dimensional) using
rand() function
i.e. rand(1, 2500). Write a program to add the two such random signals together
using simple
vector addition.
TASK 03
Using colon notation, generate the following sequence:
-65.25, -57.75, -50.25. . . . . . . . . . ., 54.75,62.25, 69.75
TASK 05
A=[3 7 -4 12
9 10 2 -5
6 13 8 11
15 5 4 1 ]
3) Create 2x3 array D consisting of all elements in the first two rows and the last three
columns of A
TASK 06
MATLAB has functions to round floating point numbers to integers. These are round, fix,
ceil, and floor. Test how these functions work. Determine the output of the following:
f = [‐.5 .1 .5];
1) round(f):
It will round off the number to whole integer if if it is .5 or greater
Like: -1 0 1
2) fix(f):
This will round off the number to some fix value in this case it is:
0 0 0
3) ceil(f)
The ceil function will round off the number to the greater number near it.
0 1 1
4) floor(f)
Simply this function is opposite to ceil function
-1 0 0
TASK 07
A=[-3 5
4 8]
Find the following:
1) Column‐wise sum of all elements of A using sum function; for information about sum
function, type help sum in matlab
2) Column‐wise product of all elements of A using prod function; for information about
prod function, type help prod in matlab
3) Length of matrix A:
4) Size of matrix A: