已知A矩阵为:
4 20 12 8
3 15 7 40
8 22 12 36
11 30 18 46
通过矩阵提取,获得:
8 0 0 4
0 7 15 0
0 12 22 0
46 0 0 11
就是保留2对角线上的值并进行交换
a=[4,20,12,8;3,15,7,40;8,22,12,36;11,30,18,46]; b=diag(a); c=diag(a(1:end,end:-1:1)); a=diag(c); d=a; d=diag(b); d=fliplr(d); z=a+d; disp(num2str(z));
标签:11,12,提取,22,46,diag,MATLAB,对角线,15 From: https://www.cnblogs.com/lachesism/p/16776860.html