如何在R中绘制多元函数

问题描述 投票:0回答:3

我正在尝试绘制以下函数:enter image description here

这是我目前正在尝试的:

curve(7*x*y/( e^(x^2+y^2)))

但出现以下错误:

enter image description here

r plot curve
3个回答
1
投票

一种绘制方式是使用contour()功能。另外,正如@Sang won kim所指出的,exp()e^(...)的功能>

x <- seq(from = 0.01, to = 2.1, by = 0.01)
y <- x

multi_var_fx <- function (x, y) {
  7 * x * y / (exp(x^2 + y^2))
}

z <- outer(x, y, multi_var_fx)

contour(x, y, z, xlab = 'x', ylab = 'y')

“”

reprex package(v0.3.0)在2019-10-27创建


0
投票

您的e表示指数函数。在r中,指数函数代码为exp()。因此,您可以修改此代码。


0
投票

您可以创建这样的轮廓图:

© www.soinside.com 2019 - 2024. All rights reserved.