ex2_1.m
A=ones(3)
A(4,5)=0
>> ex2_1
A =
1 1 1
1 1 1
1 1 1
A =
1 1 1 0 0
1 1 1 0 0
1 1 1 0 0
0 0 0 0 0
ex2_2.m
b=[1,2,4,8,16,32,64]
B=diag(b)
>> ex2_2
b =
1 2 4 8 16 32 64
B =
1 0 0 0 0 0 0
0 2 0 0 0 0 0
0 0 4 0 0 0 0
0 0 0 8 0 0 0
0 0 0 0 16 0 0
0 0 0 0 0 32 0
0 0 0 0 0 0 64
ex2_3.m
B(:)
>> ex2_3
ans =
1
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
4
0
0
0
0
0
0
0
8
0
0
0
0
0
0
0
16
0
0
0
0
0
0
0
32
0
0
0
0
0
0
0
64