《matlab高层绘图操作》由会员分享,可在线阅读,更多相关《matlab高层绘图操作(9页珍藏版)》请在金锄头文库上搜索。
1、实验六高层绘图操作一、实验目的1、掌握绘制二维图形的常用函数2、掌握绘制三维图形的常用函数3、掌握绘制图形的辅助操作二、实验内容1、设,在x=区间取101点,绘制函数的曲线。x=0:pi/50:2*pi;y=(0.5+3*sin(x)./(1+x.2).*cos(x);plot(x,y) test12、已知y1=x2,y2=,y3= y1 y2,完成下列操作: (1)在同一坐标系下用不同的颜色和线型绘制三条曲线。x=(0:pi/100:2*pi);y1=x.2;y2=cos(2*x);y3=y1.*y2;plot(x,y1,m.);hold on;plot(x,y2,g-.);hold on;
2、plot(x,y3,y-);hold off test2(2)以子图形式绘制三条曲线。x=(0:pi/100:2*pi);y1=x.2;y2=cos(2*x);y3=y1.*y2;subplot(3,1,1);plot(x,y1);title(y1);subplot(3,1,2);plot(x,y2);title(y2);subplot(3,1,3);plot(x,y3);title(y3);(3)分别用条形图、阶梯图、杆图和填充图绘制三条曲线。x=(0:pi/100:2*pi);y1=x.2;y2=cos(2*x);y3=y1.*y2;subplot(3,4,1);bar(x,y1,y);t
3、itle(bar(x,y1,y);subplot(3,4,2);stairs(x,y1,m);title(stairs(x,y1,m);subplot(3,4,3);stem(x,y1,g);title(stem(x,y1,g);subplot(3,4,4);fill(x,y1,c);title(fill(x,y1,c);subplot(3,4,5);bar(x,y2,y);title(bar(x,y2,y);subplot(3,4,6);stairs(x,y2,m);title(stairs(x,y2,m);subplot(3,4,7);stem(x,y2,g);title(stem(x,y
4、2,g);subplot(3,4,8);fill(x,y2,c);title(fill(x,y2,c);subplot(3,4,9);bar(x,y3,y);title(bar(x,y3,y);subplot(3,4,10);stairs(x,y3,m);title(stairs(x,y3,m);subplot(3,4,11);stem(x,y3,g);title(stem(x,y3,g);subplot(3,4,12);fill(x,y3,c);title(fill(x,y3,c); test43、已知 在区间绘制函数曲线。x=-5:0.1:5;if x test5;4、绘制极坐标曲线,并分
5、析参数a、b、n对曲线形状的影响。a=input(please input a=);b=input( please input b=);n=input( please input n=);theta=0:0.01:2*pi;rho=a*sin(b+n*theta);polar(theta,rho,k) test6please input a=6 please input b=7 please input n=85、绘制函数的曲面图和等高线其中x的21个值均匀分布在-5,5范围,y的31个值均匀分布在0,10,要求使用subplot(2,1,1)和subplot(2,1,2)将产生的曲面图和等高
6、线图画在同一个窗口上。x=-5:0.5:5;y=0:1/3:10;x,y=meshgrid(x,y);z=cos(x).*cos(y).*exp(-(sqrt(x.2+y.2)/4);subplot(2,2,1);surf(x,y,z);subplot(2,2,2);contour3(x,y,z); test76、绘制曲面图形,并进行插值着色处理。s=0:0.05:pi/2;t=0:0.05:3*pi/2;s,t=meshgrid(s,t);x,y,z=peaks(30);x=cos(s).*cos(t);y=cos(s).*sin(t);z=sin(s);surf(x,y,z);shading flat; test8