当前位置:首页 > matlab习题及答案
第5章 基本图形处理功能
5.1 绘制曲线y?x3?x?1,x的取值范围为[-5,5]。 >> x=-5:0.2:5; >> y=x.^3+x+1; >> plot(x,y)
5.2 有一组测量数据满足y?e-at,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')
5.3 在5.1题结果图中添加标题y?e-at,并用箭头线标识出各曲线a的取值。 >> title('\\ity\\rm=e^{-\\itat}')
>> title('\\ity\\rm=e^{-\\itat}','FontSize',12)
>> text(t(6),y1(6),'\\leftarrow\\ita\\rm=0.1','FontSize',11) >> text(t(6),y2(6),'\\leftarrow\\ita\\rm=0.2','FontSize',11) >> text(t(6),y3(6),'\\leftarrow\\ita\\rm=0.5','FontSize',11)
5.4 在5.1题结果图中添加标题y?e-at和图例框。 >> title('\\ity\\rm=e^{-\\itat}','FontSize',12) >> legend('a=0.1','a=0.2','a=0.5')
5.5表中列出了4个观测点的6次测量数据,将数据绘制成为分组形式和堆叠形式的条形图。
观测点1 观测点2 观测点3 观测点4 第1次 3 6 9 6 第2次 6 7 7 4 第3次 7 3 2 3 第4次 4 2 5 2 第5次 2 4 8 7 第6次 8 7 4 4 >> y=[3 6 9 6;6 7 7 4;7 3 2 3;4 2 5 2;2 4 8 7;8 7 4 4]; >> bar(y)
>> bar(y,’stack’)
5.6 x= [66 49 71 56 38],绘制饼图,并将第五个切块分离出来。 >> x=[66 49 71 56 38]; >> L=[0 0 0 0 1]; >> pie(x,L)
5.7 z?xe?x2?y2,当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')
5.8 绘制peaks函数的表面图,用colormap函数改变预置的色图,观察色彩的分布情况。 >> surf(peaks(30));
>> colormap(hot)
>> colormap(cool)
共分享92篇相关文档