You are on page 1of 3

Even Roll Numbers:

Q1:
(a) Create 10x10 matrix (say X) with even rows as even numbers and odd
rows as odd numbers with range of 200 to 300, with no repeated value.
(b) Take transpose of X and add to original X save it to S matrix, Take
transpose of X and subtract it from original X save it to A matrix.
(c) Append 5th row of matrix X to end of matrix A and 5th column of X to
end of matrix S, Compute Y as multiplication of A and S.
Add extra row or column of ones to A and S to make it square matrix if
needed
(d) Delete last row and last column of Y and make it 10x10 matrix and
Compute Y1 = A2 + S2
also compute inverse of Y1

Q2: Let array


>> A = [ 1 0 1 0
0202
3131]
Write commands that will perform each of the following operations on array
A:
1. Return the second column of A.
2. Return the first and third rows of A.
3. Delete the first and second columns of A.
4. Append the column vector [7; 8; 9]to A.

Q3. Each of the five columns in matrix A represents the four exam grades
for a student in
a MATLAB programming class:
A = [ 89 97 55 72 95
100 92 63 85 91
82 96 71 91 82
90 98 48 83 70 ]
1. Give a command that sorts each students grades and returns a matrix
with the
sorted grades. Sort(A)
Question:4
a. Given a vector A = [12 62 93 -8 22];
b. Create a diagonal matrix from given vector by placing the vector one row below the main

diagonal.
c. Reshape 3-by-4 matrix A to have dimensions 2-by-6

Odd roll Numbers


Q1. Each of the five columns in matrix A represents the four exam grades
for a student in
a MATLAB programming class:
A = [ 89 97 55 72 95
100 92 63 85 91
82 96 71 91 82
90 98 48 83 70 ]
a). Give a command that sorts each students grades and returns a matrix
with the
sorted grades. Sort
Q2: Create a 4-by-6 matrix named A.
-> First row contains even numbers starting from 4.
-> Second row contains odd numbers starting from 1.
-> Third row contains all ones.
-> Fourth row contains all zeros.
Operations:
a)Find sum of all elements of second row.
b)Append one row at the end that contains all 5s.
c)Delete third row
d)Replace first row with all threes(3s).

Q3.a) ) Create a matrix A with dimension 10X10 with range of 250 to 350
without repeating any value, take 2nd, 5th, 7th, 9th rows of matrix A (using
indexing) and make a new matrix B using appropriate concatenation
method.
(b) Flip the B matrix along horizontal axis and sort the elements in
ascending order in both dimensions and shift it to the right along the
second (horizontal) dimension by three places and store these values in
matrix C.
Q4. Create a 4-by-6 matrix named A and shift it along both dimensions: three columns to the

right and two rows up


d. Given a vector A = [1 2 3 4 5 6 7];

Create a diagonal matrix from given vector by placing the vector one row below the main
diagonal.
e. Create a 4 X 4 matrix with ones on the diagonal and zeros elsewhere.
f. Given a vector A = [12 62 93 -8 22];
g. Create a diagonal matrix from given vector by placing the vector one row below the main
diagonal.
h. Reshape 3-by-4 matrix A to have dimensions 2-by-6

You might also like