英文:
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<-(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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论