数组运算符
表的构建
n为列向量元素由0到9。
n=(0:9)';
构建一个平方和2次幂的表。
pows=[n n.^2 2.^n]
>> pows=[n n.^2 2.^n]
pows =
0 0 1
1 1 2
2 4 4
3 9 8
4 16 16
5 25 32
6 36 64
7 49 128
8 64 256
9 81 512
构建一个对数表
format short g
x=(1:0.1:2)';
logs=[x log10(x)]
logs=[x log10(x)]
logs =
1 0
1.1 0.041393
1.2 0.079181
1.3 0.11394
1.4 0.14613
1.5 0