为间隔中等间距x生成x,y的值

时间:2021-02-22 20:22:26

I am new to working in R and I would like to generate values of x,y to plot for lowess smoothing. I would like to generate equally spaced x values in an interval for a given function.

我是R的新手,我想生成x,y的值来绘制低值平滑。我想在给定函数的间隔中生成等间距的x值。

For example, I would like to generate the values for the function:

例如,我想生成函数的值:

f(x) = 5x^3 - 2x^2 -2x +1 

in the interval of [-5,5].

在[-5,5]的区间内。

(p.s. my background is in biology so I don't understand the technical things as well as I would like!)

(p.s.我的背景是生物学,所以我不理解我想要的技术方面!)

1 个解决方案

#1


1  

You mean something like this

你的意思是这样的

f1 <- function(x) (5*x)^3 - (2*x)^2 - 2*x + 1
seqx <- seq(-5,5, by = 0.1)
plot(seqx, f1(seqx), pch = 20)

为间隔中等间距x生成x,y的值

#1


1  

You mean something like this

你的意思是这样的

f1 <- function(x) (5*x)^3 - (2*x)^2 - 2*x + 1
seqx <- seq(-5,5, by = 0.1)
plot(seqx, f1(seqx), pch = 20)

为间隔中等间距x生成x,y的值