Matlab n阶矩阵行、列互换

>>
>> Z2=eye(4,4)

Z2 =

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

>>
>>
>>

>>
>> Z2([2,3],:)=Z2([3,2],:)

Z2 =

1 0 0 0
0 0 1 0
0 1 0 0
0 0 0 1

>>
>>
>> A2=[1,2,3,4;2,3,4,5;3,4,5,6;4,5,6,7]

A2 =

1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7

>>
>>
>> N2=A2*Z2

N2 =

1 3 2 4
2 4 3 5
3 5 4 6
4 6 5 7

>>
>>
>> N3=Z2*A2

N3 =

1 2 3 4
3 4 5 6
2 3 4 5
4 5 6 7

>>
>>

上一篇:请实现字符串从两边逐渐聚拢


下一篇:Python编程之按序输出