第一题:
A = pascal(7) %生成7*7 pascal矩阵
B = A([1,3,5],[5,6,7]) %构成矩阵B
C = A(5:7,1:3) %构成矩阵C
D = B-1*C
A =
1 1 1 1 1 1 1
1 2 3 4 5 6 7
1 3 6 10 15 21 28
1 4 10 20 35 56 84
1 5 15 35 70 126 210
1 6 21 56 126 252 462
1 7 28 84 210 462 924
B =
1 1 1
15 21 28
70 126 210
C =
1 5 15
1 6 21
1 7 28
D =
0 -4 -14
14 15 7
69 119 182
第二题:
function A=prime_number()
N=100;
j=1;
for i=2:N
if prod(rem(i,2:(i-1)))~=0
A(j)=i;
j=j+1;
end
end
A =
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97