UNIVERSITY OF ENGINEERING & TECHNOLOGY, TAXILA
SUBMITTED BY: MUHAMMAD UBAID ASHRAF
REG. NUMBER: 20-CP-09
SECTION: ALPHA
SEMESTER: 3rd
Q1- Define and operate with the vectors
V1 = [1 2 3 4 5 6 7 8 9 0]
V2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9]
V3 = [4 4 4 4 3 3 2 2 2 1]
a) Calculate, respectively, the sum of all the elements in vectors V1, V2, and V3
b) How to get the value of the fifth element of each vector? What happens if we
execute the command V1(0) and V1(11)? Remember if a vector has N elements,
their subscripts are from 1 to N.
c) Generate a new vector V4 from V2, which is composed of the first five
elements of V2.
d) Generate a new vector V5 from V2, which is composed of the last five
elements of V2.
e) Derive a new vector V6 from V2, with its 6th element omitted.
f) Derive a new vector V7 from V2, with its 7th element changed to 1.4.
g) Derive a new vector V8 from V2, whose elements are the 1st, 3rd, 5th, 7th,
and 9thelements of V2.
h) What are the results of
9-V1
V1*5
V1+V2
V1-V3
V1.*V2
V1.*V2
V1.^2
V1.^V3
V1^V3
V1 == V3
V1>6
V1>V3
Q2) Extract a 4x4 matrix from the 6x6 matrix and 4x1 matrix from 6x1.
Q3) Find the inverse of a 2x2 matrix using MATLAB.
Q4) Generate a 4x5 zero’s matrix and 4x5one’s matrix and add them.
Q5) Suppose if a=1 2 3;4 5 6;7 8 9. Then, using zero’s matrix command, write a
command(s)so that the output becomes: a=1 2 3;4 5 6;7 8 9;0 0 0;0 0 0
Q6) Suppose if a=1 2 3; 4 5 6;7 8 9. Then, using zero’s matrix command, write a
command(s)so that the output becomes : a=1 2 3;0 4 5;6 0 7;8 9 0.