15符号函数绘图法绘制函数x=sin(3t)cos(t),y=sin(3t)sin(t)的图形,
t 的变化范围为[0,2π] >> syms t
>> ezplot(sin(3*t)*cos(t),sin(3*t)*sin(t),[0,2*pi])
-at y =e 16有一组测量数据满足,t 的变化范围为0~10,用不同
的线型和标记点画出a=0.1、a=0.2和a=0.5三种情况下的曲线,并加入标题和图列框(用代码形式生成) >> t=0:0.5:10; >> y1=exp(-0.1*t); >> y2=exp(-0.2*t); >> y3=exp(-0.5*t);
>> plot(t,y1,'-ob',t,y2,':*r',t,y3,'-.^g')
>> title('\ity\rm=e^{-\itat}','FontSize',12) >>
legend('a=0.1','a=0.2','a=0.5')
17 x= [66 49 71 56 38],绘制饼图并将第五个切块分离 >> x=[66 49 71 56 38]; >> L=[0 0 0 0 1]; >> pie(x,L) 18
z =xe -x
2
-y 2
,当x 和y 的取值范围均为-2到2时,用建立子窗口
的方法在同一个图形窗口中绘制出三维线图、网线图、表面图和带渲染效果的表面图
>> [x,y]=meshgrid([-2:.2:2]); >> z=x.*exp(-x.^2-y.^2);
>> mesh(x,y,z)
>> subplot(2,2,1), plot3(x,y,z) >> title('plot3 (x,y,z)')
>> subplot(2,2,2), mesh(x,y,z) >> title('mesh (x,y,z)') >> subplot(2,2,3), surf(x,y,z) >> title('surf (x,y,z)')
>> subplot(2,2,4), surf(x,y,z), shading interp >>
title('surf (x,y,z), shading interp')
19 在区间[-1, 1]画出函数y =sin 1的图形 x
程序如下:
>> fplot('sin(1/x)',[-pi/12,pi/12]) >> grid
>> title('graph of sin(1/x)') 结果如下:
graph of sin(1/x)
2223
20 分别画出坐标为(i , i ), (i , 4i +i ), (i =1, 2, , 10) 的散点图, 并
画出折线图
程序如下: >> for i=1:10
plot(i,i.^2,'.'); hold on
plot(i.^2,4*i.^2+i.^3,'.'); end
>> x=1:10; >> y=x.^2; >> plot(x,y);
>> plot(x.^2,4*x.^2+x.^3); >> axis([0,105,0,1450]) 结果如下:
21在区间[-4, 4]上作出函数f (x ) =x 3-9x 的图形, 并计算x lim f (x ) 和 →∞
x -x
lim f (x ).
x 1
程序如下: >> syms x;
>> f=(x^3-9*x)/(x^3-x); >> limit(f,x,inf) ans = 1
>> limit(f,x,1) ans = NaN
绘制f (x ) 的图形程序如下:
>> f=inline('(x.^3-9*x)./(x.^3-x)'); >> x=-4:0.01:4;
>>plot(x,f(x))
15符号函数绘图法绘制函数x=sin(3t)cos(t),y=sin(3t)sin(t)的图形,
t 的变化范围为[0,2π] >> syms t
>> ezplot(sin(3*t)*cos(t),sin(3*t)*sin(t),[0,2*pi])
-at y =e 16有一组测量数据满足,t 的变化范围为0~10,用不同
的线型和标记点画出a=0.1、a=0.2和a=0.5三种情况下的曲线,并加入标题和图列框(用代码形式生成) >> t=0:0.5:10; >> y1=exp(-0.1*t); >> y2=exp(-0.2*t); >> y3=exp(-0.5*t);
>> plot(t,y1,'-ob',t,y2,':*r',t,y3,'-.^g')
>> title('\ity\rm=e^{-\itat}','FontSize',12) >>
legend('a=0.1','a=0.2','a=0.5')
17 x= [66 49 71 56 38],绘制饼图并将第五个切块分离 >> x=[66 49 71 56 38]; >> L=[0 0 0 0 1]; >> pie(x,L) 18
z =xe -x
2
-y 2
,当x 和y 的取值范围均为-2到2时,用建立子窗口
的方法在同一个图形窗口中绘制出三维线图、网线图、表面图和带渲染效果的表面图
>> [x,y]=meshgrid([-2:.2:2]); >> z=x.*exp(-x.^2-y.^2);
>> mesh(x,y,z)
>> subplot(2,2,1), plot3(x,y,z) >> title('plot3 (x,y,z)')
>> subplot(2,2,2), mesh(x,y,z) >> title('mesh (x,y,z)') >> subplot(2,2,3), surf(x,y,z) >> title('surf (x,y,z)')
>> subplot(2,2,4), surf(x,y,z), shading interp >>
title('surf (x,y,z), shading interp')
19 在区间[-1, 1]画出函数y =sin 1的图形 x
程序如下:
>> fplot('sin(1/x)',[-pi/12,pi/12]) >> grid
>> title('graph of sin(1/x)') 结果如下:
graph of sin(1/x)
2223
20 分别画出坐标为(i , i ), (i , 4i +i ), (i =1, 2, , 10) 的散点图, 并
画出折线图
程序如下: >> for i=1:10
plot(i,i.^2,'.'); hold on
plot(i.^2,4*i.^2+i.^3,'.'); end
>> x=1:10; >> y=x.^2; >> plot(x,y);
>> plot(x.^2,4*x.^2+x.^3); >> axis([0,105,0,1450]) 结果如下:
21在区间[-4, 4]上作出函数f (x ) =x 3-9x 的图形, 并计算x lim f (x ) 和 →∞
x -x
lim f (x ).
x 1
程序如下: >> syms x;
>> f=(x^3-9*x)/(x^3-x); >> limit(f,x,inf) ans = 1
>> limit(f,x,1) ans = NaN
绘制f (x ) 的图形程序如下:
>> f=inline('(x.^3-9*x)./(x.^3-x)'); >> x=-4:0.01:4;
>>plot(x,f(x))