MATLAB矩阵测试

import matplotlib.pyplot as plt
import networkx as nx

G = nx.star_graph(30)
pos = nx.spring_layout(G)
colors = range(30)

nx.draw(G, pos, node_color=’#A0CBE5’, edge_color=colors,
width=4, edge_cmap=plt.cm.gist_heat, with_labels=False)
plt.show()
在这里插入图片描述
nx.draw(G, pos, node_color=’#A0CBE5’, edge_color=colors,
width=4, edge_cmap=plt.cm.gist_heat, with_labels=False)
在这里插入图片描述
nx.draw(G, pos, node_color=’#A0CBE5’, edge_color=colors,
width=4, edge_cmap=plt.cm.gist_heat, with_labels=True)
在这里插入图片描述
nx.draw(G, pos, node_color=’#A0CBE5’, edge_color=colors,
width=4, edge_cmap=plt.cm.gist_heat, with_labels=True)
在这里插入图片描述

randperm(1)

ans =

 1

randperm(2)

ans =

 2     1

randperm(3)

ans =

 3     2     1

randperm(4)

ans =

 1     2     3     4

randperm(5)

ans =

 1     4     5     3     2

randperm(6)

ans =

 1     2     6     4     3     5

randperm(7)

ans =

 1     7     4     6     5     2     3

randperm(7)

ans =

 1     7     4     6     5     2     3

randperm(8)

ans =

 4     6     7     2     5     1     3     8

randperm(9)

ans =

 4     9     2     6     5     1     7     8     3

randperm(10)

ans =

10 9 6 2 1 3 8 7 4 5

eye(1)

ans =

 1

eye(2)

ans =

 1     0
 0     1

eye(3)

ans =

 1     0     0
 0     1     0
 0     0     1

eye(4)

ans =

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

eye(5)

ans =

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

eye(-1)

ans =

 []

eye(-3)

ans =

 []

eye(0)

ans =

 []

eye(6)

ans =

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

ones(1,2)

ans =

 1     1

ones(1,3)

ans =

 1     1     1

ones(2,2)

ans =

 1     1
 1     1

ones(2,3)

ans =

 1     1     1
 1     1     1

ones(3,3)

ans =

 1     1     1
 1     1     1
 1     1     1

hilb(1)

ans =

 1

hilb(2)

ans =

1.0000    0.5000
0.5000    0.3333

hilb(3)

ans =

1.0000    0.5000    0.3333
0.5000    0.3333    0.2500
0.3333    0.2500    0.2000

hilb(4)

ans =

1.0000    0.5000    0.3333    0.2500
0.5000    0.3333    0.2500    0.2000
0.3333    0.2500    0.2000    0.1667
0.2500    0.2000    0.1667    0.1429

hilb(5)

ans =

1.0000    0.5000    0.3333    0.2500    0.2000
0.5000    0.3333    0.2500    0.2000    0.1667
0.3333    0.2500    0.2000    0.1667    0.1429
0.2500    0.2000    0.1667    0.1429    0.1250

0.2000 0.1667 0.1429 0.1250 0.1111

hilb(1.2)

ans =

 1

hilb(3.2)

ans =

1.0000    0.5000    0.3333
0.5000    0.3333    0.2500
0.3333    0.2500    0.2000

hilb(-1.2)

ans =

 []

hilb(0)

ans =

 []

hilb(2)

ans =

1.0000    0.5000
0.5000    0.3333

hilb(4.5)

ans =

1.0000    0.5000    0.3333    0.2500
0.5000    0.3333    0.2500    0.2000
0.3333    0.2500    0.2000    0.1667
0.2500    0.2000    0.1667    0.1429

A=[7 8 2;-3 5 9;1 2 -3]

A =

 7     8     2
-3     5     9
 1     2    -3

flipud(A)

ans =

 1     2    -3
-3     5     9
 7     8     2

fliplr(A)

ans =

 2     8     7
 9     5    -3
-3     2     1

rot90(A)

ans =

 2     9    -3
 8     5     2
 7    -3     1

B=randn(3,4)

B =

-0.0068 0.3714 -1.0891 1.1006
1.5326 -0.2256 0.0326 1.5442
-0.7697 1.1174 0.5525 0.0859

flipud(B)

ans =

-0.7697 1.1174 0.5525 0.0859
1.5326 -0.2256 0.0326 1.5442
-0.0068 0.3714 -1.0891 1.1006

fliplr(B)

ans =

1.1006   -1.0891    0.3714   -0.0068
1.5442    0.0326   -0.2256    1.5326
0.0859    0.5525    1.1174   -0.7697

rot90(B)

ans =

1.1006    1.5442    0.0859

-1.0891 0.0326 0.5525
0.3714 -0.2256 1.1174
-0.0068 1.5326 -0.7697

magic(4)

ans =

16     2     3    13
 5    11    10     8
 9     7     6    12
 4    14    15     1

magic(3)

ans =

 8     1     6
 3     5     7
 4     9     2

diag(B,3)

ans =

1.1006

diag(B,2)

ans =

-1.0891
1.5442

diag(B,1)

ans =

0.3714
0.0326
0.0859

diag(B,0)

ans =

-0.0068
-0.2256
0.5525

diag(B,-2)

ans =

-0.7697

diag(B,-3)

ans =

空的 0×1 double 列向量

diag(B,-1)

ans =

1.5326
1.1174

randn(3,4)

ans =

-1.4916 2.3505 -0.1924 -1.4023
-0.7423 -0.6156 0.8886 -1.4224
-1.0616 0.7481 -0.7648 0.4882

randn(4,5)

ans =

-0.1774 0.1978 0.8351 -1.1480 -0.6669
-0.1961 1.5877 -0.2437 0.1049 0.1873
1.4193 -0.8045 0.2157 0.7223 -0.0825
0.2916 0.6966 -1.1658 2.5855 -1.9330

randn(3,2)

ans =

-0.4390 -0.8880
-1.7947 0.1001
0.8404 -0.5445

randn(2,2)

ans =

0.3035    0.4900

-0.6003 0.7394
randn(3,2)

ans =

-0.4390 -0.8880
-1.7947 0.1001
0.8404 -0.5445

randn(2,2)产生2*2维正太分布随机矩阵

ans =

0.3035    0.4900

-0.6003 0.7394

rand(2,2)

ans =

0.7482    0.0838
0.4505    0.2290

rand(3,2)

ans =

0.9133    0.5383
0.1524    0.9961
0.8258    0.0782

rand(2,3)%产生2*3维随机变量

ans =

0.4427    0.9619    0.7749
0.1067    0.0046    0.8173

zeros(2,3)

ans =

 0     0     0
 0     0     0

zeros(2,2)

ans =

 0     0
 0     0

zeros(3,3)

ans =

 0     0     0
 0     0     0
 0     0     0

logspace(1,2)

ans =

1 至 17 列

10.0000 10.4811 10.9854 11.5140 12.0679 12.6486 13.2571 13.8950 14.5635 15.2642 15.9986 16.7683 17.5751 18.4207 19.3070 20.2359 21.2095

18 至 34 列

22.2300 23.2995 24.4205 25.5955 26.8270 28.1177 29.4705 30.8884 32.3746 33.9322 35.5648 37.2759 39.0694 40.9492 42.9193 44.9843 47.1487

35 至 50 列

49.4171 51.7947 54.2868 56.8987 59.6362 62.5055 65.5129 68.6649 71.9686 75.4312 79.0604 82.8643 86.8511 91.0298 95.4095 100.0000
logspace(2,3)

ans =

1.0e+03 *

1 至 17 列

0.1000    0.1048    0.1099    0.1151    0.1207    0.1265    0.1326    0.1389    0.1456    0.1526    0.1600    0.1677    0.1758    0.1842    0.1931    0.2024    0.2121

18 至 34 列

0.2223    0.2330    0.2442    0.2560    0.2683    0.2812    0.2947    0.3089    0.3237    0.3393    0.3556    0.3728    0.3907    0.4095    0.4292    0.4498    0.4715

35 至 50 列

0.4942    0.5179    0.5429    0.5690    0.5964    0.6251    0.6551    0.6866    0.7197    0.7543    0.7906    0.8286    0.8685    0.9103    0.9541    1.0000

logspace(2,3,4)

ans =

1.0e+03 *

0.1000    0.2154    0.4642    1.0000

logspace(2,3,5)

ans =

1.0e+03 *

0.1000    0.1778    0.3162    0.5623    1.0000

logspace(2,3,7)

ans =

1.0e+03 *

0.1000    0.1468    0.2154    0.3162    0.4642    0.6813    1.0000
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值