I would like to plot a function several times, each time changing a parameter (a constant) in the function. How can i do this?
fun1 <- function(x, b) abs(x^2 - b^2)
plot(fun1(b=0.1),-1, 1)
plot(fun1(b=0.2),-1, 1, add=TRUE)
只是在for-loop
推广了相同的方法:
for (b in c(0.1,0.2))curve(abs(x^2 - b^2),add=TRUE,col='red')
try this:
curve(abs(x^2 - 0.1^2), -1, 1)
curve(abs(x^2 - 0.2^2), -1, 1, add = TRUE)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.