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

LAB TASKS:

2)
Generate
the
follo
win
g
vect
or

1) Investigate the effect of the


following commands:
i. v(2)
ii. sum =v+w
iii. diff = v w
iv. vw=[v w]
v. vw(2:6)
vi. v

v=[ 1 2 3 ; 4 5 6];
w=[ 3 2 1 ; 6 5 4];
v(2)
ans =

Investigate the effect


following commands
i. z
ii. z*v
w]
iv. v*z
v. [z; v]
v

sum= v+w
sum =
4
4
10 10

z=[1 ; 1 ; 0 ; 0 ]
z=

diff= v-w
diff =
-2
-2

0
0

1
1
0
0

2
2

vw= [v w]
vw =
1
4

v=[1 ; 2 ; 3 ; 4]
v=

2
5

3
6

3
6

2
5

1
4

1
2
3
4

vw(2:6)
ans =
4

1
2
3

z'
ans =

v'
ans =

1
4
5
6

0

0

4
10

1
1

v'
ans =
1
v=v'

of

the

iii. [v;
vi. z +

v=
1

2
2
0
0

3
3
0
0

4
4
0
0

z*v
ans =
1
1
0
0

w=[5 ; 6 ; 7 ; 8]
w=
5
6
7
8

ans =
6

w=w'
w=
5

ans =
3
[z ; v']
ans =
1

i. N = inv(M)
= eye(2)
iv. M + I
v(3:4)*M
vii. M(1,1)
ix. M(:,1)

ii. M*N
v. M*z(1:2)
viii. M(1:2,1:2)
x. M(2,:)

M=[1 2; 3 4]
M=

ans =

v*z

2
3
3
4

[v ; w]

1
5

z+v'
ans =

3) Generate following matrix &


then investigate the effect of the
commands given below:
1 2
M

3 4

w'

1
0
0
1
2
3
4

2
6

3
7

4
8

1
3

2
4

N=inv(M)
N=
-2.0000 1.0000
1.5000 -0.5000
M*N
ans =
1.0000
0.0000

0
1.0000

iii. I
vi.

3
7
I=eye(2)

v=[1 2 3 4]'
v=

I=
1
0

0
1

1
2
3
4

M+I
ans =
2
3

v=v'
v=

2
5

z=[1 1 0 0];
z'
ans =

15

22

M(1,1)
ans =
1

z'
ans =

M(1:2,1:2)
ans =

1
1
0
0

1
3

2
4

M(2,:)
ans =

z
z=
1

z=z'
z=
1
1
0
0
M*z(1:2)
ans =

v(3:4)*M
ans =

1
1
0
0

M(:,1)
ans =
1
3

3)
Type
follo
win
g

com
man
ds
in
the
MAT
LAB
com
man
d
win
dow
,
and
the
n
obs
erve
the

out
put.
X = linspace(6,10,1000);
Y = logspace(6,10,1000);
plot(X,Y)

You might also like