1. 创建一个5*5随机矩阵,并求逆。
>> A = rand(5)
A =
0.2760 0.4984 0.7513 0.9593 0.8407
0.6797 0.9597 0.2551 0.5472 0.2543
0.6551 0.3404 0.5060 0.1386 0.8143
0.1626 0.5853 0.6991 0.1493 0.2435
0.1190 0.2238 0.8909 0.2575 0.9293
>> B = inv(A)
B =
2.0136 -2.8049 3.8768 2.5923 -5.1307
-2.6004 3.7771 -3.1101 -2.2325 4.6294
2.0003 -3.2808 2.3277 3.8360 -3.9569
2.1201 -1.1358 0.5437 0.5977 -2.2404
-2.1368 2.9095 -2.1297 -3.6376 5.0326
2. 创建一个4*3随机矩阵,求逆。用到的函数与第一问相同,能否互换?
>> C = rand(4,3)
C =
0.3500 0.4733 0.5497
0.1966 0.3517 0.9172
0.2511 0.8308 0.2858
0.6160 0.5853 0.7572
>> D = pinv(C)
D =
0.4852 -1.9450 -1.1779 2.4484
0.0153 0.0536 1.6698 -0.7064
0.0492 1.4575 -0.4174 -0.3229
不能互换。
3. 用两个方法求解Ax=b的解。(A为4阶随机矩阵,b为4阶列向量)
>> A = rand(4)
A =
0.7537 0.0540 0.1299 0.3371
0.3804 0.5308 0.5688 0.1622
0.5678 0.7792 0.4694 0.7943
0.0759 0.9340 0.0119 0.3112
>> b = ones(4,1)
b =
1
1
1
1
>> x = inv(A)*b
x =
1.7760
1.2923
-0.3262
-1.0855
>> x_1 = A\b
x_1 =
1.7760
1.2923
-0.3262
-1.0855
4. 调用上题中的A,计算A的5次方。
A^5
ans =
2.0698 2.4118 1.3948 1.6407
3.7887 4.4991 2.6145 3.0264
5.3305 6.3443 3.6658 4.2776
2.7799 3.3410 1.9175 2.2302
5. 还是利用上面的A,计算(0.5)^A的值。
(0.5)^A
ans =
0.6058 + 0.0000i 0.0413 - 0.0000i -0.0627 + 0.0000i -0.1468 + 0.0000i
-0.1241 + 0.0000i 0.7760 - 0.0000i -0.2839 - 0.0000i 0.0106 + 0.0000i
-0.2204 - 0.0000i -0.2675 + 0.0000i 0.7948 + 0.0000i -0.3880 - 0.0000i
0.0128 - 0.0000i -0.5030 + 0.0000i 0.0899 - 0.0000i 0.8185 - 0.0000i