小编Pau*_*.P.的帖子

R绘图积分

我在R中的集成功能遇到了一些问题.我试图绘制积分的声音,但似乎我做得不好.

t <- seq(0, 0.04, 0.0001)
vi <- function(x) {5 * sin(2 * pi * 50 * x)}
vo <- function(x) {integrate(vi, lower=0, upper=x)$value}

test_vect = Vectorize(vo, vectorize.args='x')
plot(t, vo(t))  # should be a cosine wave
plot(t, vi(t))  # sine wave
Run Code Online (Sandbox Code Playgroud)

vo应该是一个正弦波,但使用test_vect给我错误的情节和vo直接使用给出错误'x'和'y'长度不同.请问有人可以帮我解决这个问题吗?

plot r integral numerical-integration

2
推荐指数
1
解决办法
1032
查看次数

标签 统计

integral ×1

numerical-integration ×1

plot ×1

r ×1