利用diag()函数和flipud()产生下列矩阵,然后求解a阵的转置矩阵aa及b阵的所有元素和,并利用reshape将aa阵变换成行向量。
题解:
c1=diag([2,5,8],0);
c2=diag([3,5],1);
a=c1+c2
b=flipud(a)
aa=a'
bb=sum(b(:))
aaa=reshape(aa,1,9)
输出:
a =
2 3 0
0 5 5
0 0 8
b =
0 0 8
0 5 5
2 3 0
aa =
2 0 0
3 5 0
0 5 8
bb =
23
aaa =
2 3 0 0 5 5 0 0 8