[英]Creating 1D zero array in Octave
How can we create an array with n
elements.我们如何创建一个包含
n
元素的数组。 zeros
function can create only arrays of dimensions greater than or equal to 2? zeros
函数只能创建维度大于或等于 2 的数组? zeros(4)
, zeros([4])
and zeros([4 4])
all create 2D zero matrix of dimensions 4x4. zeros(4)
、 zeros([4])
和zeros([4 4])
都创建了维度为 4x4 的二维零矩阵。
I have a code in Python where I have used numpy.zeros(n)
.我在 Python 中有一个代码,我在其中使用了
numpy.zeros(n)
。 I wish to do something similar in Octave.我希望在 Octave 中做类似的事情。
zeros(n,1)
在 Octave 中对我来说效果很好。
A vector is a row vector in Octave.向量是 Octave 中的行向量。 So if you want to create a vector of zeros, you need to use the command:
因此,如果要创建零向量,则需要使用以下命令:
b = zeros(1,n)
The command命令
c = zeros(n,1)
will create a column vector of zeros.将创建一个零列向量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.