创建和填充一个数组

huangapple go评论61阅读模式
英文:

Creating and filling an array

问题

我正在尝试创建一个由在指定增量z下介于'x'和'y'之间的值填充的数组。

我尝试从Matlab中将代码“翻译”为:

b <- seq(0.7, 1.2, by = 0.1)

但这只返回一个单一的值 -> 0.7

理想情况下,我希望代码返回数组[0.7, 0.8, 0.9, 1.0, 1.1, 1.2]。

英文:

I am trying to create an array populated with values between 'x' and 'y' at specified increment z.

I have tried to 'translate' the code from Matlab as

b&lt;-(0.7:0.1:1.2)

but this just returns a single value -> 0.7

Ideally I would have liked the code to return the array [0.7, 0.8, 0.9, 1.0, 1.1, 1.2]

答案1

得分: 1

你尝试过使用 seq() 函数 吗?

b <- seq(from = 0.7, to = 1.2, by = 0.1)
英文:

Have you tried using the seq() function?

b &lt;- seq(from = 0.7, to = 1.2, by = 0.1)

huangapple
  • 本文由 发表于 2023年7月10日 22:32:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76654782.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定