Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我一直在 MATLAB 中使用冒号运算符通过以下方式创建向量:
j:i:k => [j, j + i, j + 2i, ..., j + m * i]
但现在我需要创建一个这样的向量:
[i, 2i, 4i, 8i, 16i, ... etc]
如何使用冒号运算符执行此操作?
你可以这样做:
(2.^[0:n]) * i
您之前已经使用某个变量定义了一个算术序列i,即
i
n = (0:4); i = 2; a = i*n; >> i*n ans = 0 2 4 6 8
您现在要定义的是几何序列,或者
a = i*2.^n >> i*2.^n ans = 2 4 8 16 32
您也可以使用上面的方法来定义使用虚数单位的复杂i序列
a = 1i*2.^n