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

转自:http://msemac.redwoods.edu/~darnold/math50c/matlab/contours/index.xhtmlContour Maps in MatlabIn this activity we will introduceMatlab'scontourcommand,which is used to plot the level curves of a m...
摘要由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 u

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值