matlab中contourm,MATLAB 中contour函数的使用

本文介绍了如何在 MATLAB 中使用 contour 命令来绘制多变量函数的等高线图。通过示例解释了等高线的概念,展示了如何为函数 f(x,y)=x^2+y^2 绘制等高线图,并讨论了如何添加标签、强制绘制特定高度的等高线以及将等高线图与表面图结合。" 97780518,8250505,可信计算深度解析:从硬件到阿里云实践,"['可信计算', '硬件安全', '等保2.0', '阿里云安全', '系统软件']
摘要由CSDN通过智能技术生成

转自:http://msemac.redwoods.edu/~darnold/math50c/matlab/contours/index.xhtml

Contour Maps in Matlab

In this activity we will introduce

Matlab's contour command,

which is used to plot the level curves of a multivariable function.

Let's begin with a short discussion of the level curve concept.

Level Curves

Hikers and backpackers are likely to take along a copy of a

topographical map when verturing into the wilderness (see Figure

1).

a4c26d1e5885305701be709a3d33442f.png

A topographical map has lines of constant height.

If you walk along one of the contours shown in Figure 1, you will

neither gain nor lose elevation. You're walking along a curve of

constant elevation. If you walk directly perpendicular to a

contour, then you are either walking directly downhill or uphill.

When the contours are far apart, the gain or loss in elevation is

gradual. When the contours are close together, the gain or loss in

elevation is quite rapid.

The level curves of a multivariate function are analogous to the

contours in the topographical map. They are curves of constant

elevation. Let's look at an example.

Sketch several

level curves of the function f(x,y)=x2+y2.

Solution:We are interested in

finding points of constant elevation, that is, solutions of the

equation

f(x,y)=c,

where c is

a constant. Equivalently, we wish to sketch solutions of

x2+y2=c,

where c is

a constant. Of course, these "level curves" are circles, centered

at the origin, with radius c. These level

curves are drawn in Figure 2 for

constants c=0, 1, 2, 3, and

4.

Level curves of f(x,y)=x2+y2 lie

in the xy-plane.

Matlab:It's a simple task to

draw the level curves of Figure 2 using

Matlab's contour command.

We begin as if we were going to draw a surface, creating a grid

of (x,y) pairs

with the meshgridcommand.

x=linspace(-3,3,40);

y=linspace(-3,3,40);

[x,y]=meshgrid(x,y);

We then use the function f(x,y)=x2+y2, or

equivalently, z=x2+y2, to

calculate the z-values.

z=x.^2+y.^2;

Where we would normally use

the mesh command

to draw the surface, instead we

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值