
上QQ阅读APP看书,第一时间看更新
1.7 用MATLAB求函数的极限
为了更好地了解函数的特点,我们常常需要画出函数的图形,需要了解函数在自变量的某种趋势下的极限,但是有的函数比较复杂,这时可以借助于MATLAB软件来绘制函数的图形以及求函数的极限.
1.7.1 绘制一元函数的图像
绘制一元函数图像的命令如表1.7.1所示.
表 1.7.1

【例1】 在同一个坐标系下画出两条曲线y=sin x和y=cos x在[0,2π]上的图像.
解 方法一:

按Enter键,图像如图1.7.1所示.
方法二:

按Enter键,图像如图1.7.1所示.

图 1.7.1
图像完成后,可用axis([xmin,xmax,ymin,ymax])命令来调整图轴的范围,例如:axis([0,1,0,2])表示x轴的取值范围为[0,1],y轴的取值范围为[0,2].
此外,也可对图形加上各种注解与处理:

例如,输入命令:

按Enter键,图像如图1.7.2所示.
【例2】 将屏幕窗口分成4个窗口,用subplot(m,n,k)命令画4个子图,分别是:
(1)y=5x4-3x2+2x-7,x∈[-5,5]; (2)y=x2-4x+2,x∈[-1,5];


图 1.7.2
注意
subplot(m,n,k)表示将屏幕窗口分成m×n个窗口,在第k个窗口绘制第k个图形.

按Enter键,四个子图的图像如图1.7.3所示.其中,每个子图的标题可以通过命令title(函数表达式)或图片菜单来设置.

图 1.7.3

图 1.7.3(续)
1.7.2 计算函数的极限
计算函数极限的命令如表1.7.2所示.
【例3】 利用MATLAB探究下列函数的极限是否存在.


所以.
表 1.7.2


由于右极限不存在,所以
不存在.
MATLAB只用一个命令就可以求出表达式比较复杂的函数的极限,它可以帮助用户了解函数的变化特点,但应注意它只是辅助学习数学工具之一.
【例4】 用MATLAB计算下列极限:








