如何在Octave或Matlab中绘制带有两个变量的函数? [英] How can I plot a function with two variables in Octave or Matlab?

查看:149
本文介绍了如何在Octave或Matlab中绘制带有两个变量的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Octave绘制具有两个变量的相当简单的函数,例如:f(x,y)= x ^ 2 + 3y.绘制单个变量函数非常容易,但是我很难找出如何执行两个变量函数.有人知道这样做的最好方法吗?

I want to use Octave to plot fairly simple functions with two variables like: f(x,y) = x^2 + 3y . It is very easy to plot single variable functions, but I am having a lot of trouble finding out how to do two variable functions. Does anyone know the best way of doing this?

推荐答案

绘制两个变量的函数通常表示3维图-在MATLAB中,您可以使用plot3函数.要在X和Y的间隔[-10,10]中绘制函数f(x,y),可以使用以下命令:

Plotting a function of two variables would normally mean a 3-dimensional plot - in MATLAB you would use the function plot3 for that. To plot your function f(x,y) in the interval [-10,10] for both X and Y, you could use the following commands:

x = [-10:.1:10];
y = [-10:.1:10];
plot3(x, y, x.^2 + 3*y)
grid on

这篇关于如何在Octave或Matlab中绘制带有两个变量的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆