资源描述:
《matlab画函数图像》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Matlab画函数图像代码算法2010-06-0913:32:54阅读234评论2字号:大中小http://wswzxwstcwa.blog.163.com/blog/static/2052877920086250294907/前几天做家教,教Matlab画函数图像,原想学了四年应该没什么问题,可真去教起来,觉得四年都白学了,画几张图费了我两天时间,虽说最后做出来了,可是依然一知半解的.下面将这几天所做的图像及程序小记一下(望大虾指教)一、螺旋线1.静态螺旋线a=0:0.1:20*pi;h=plot3(a.*cos(a),a.*sin(a),2.*a,'b','linewidth
2、',2);axis([-50,50,-50,50,0,150]);gridonset(h,'erasemode','none','markersize',22);xlabel('x轴');ylabel('y轴');zlabel('z轴');title('静态螺旋线'); 2.动态螺旋线t=0:0.1:10*pi;i=1;h=plot3(sin(t(i)),cos(t(i)),t(i),'*','erasemode','none');gridonaxis([-22-22035])fori=2:length(t) set(h,'xdata',sin(t(i)),'ydata',c
3、os(t(i)),'zdata',t(i)); drawnow pause(0.01)endtitle('动态螺旋线');(图略) 3.圆柱螺旋线t=0:0.1:10*pi;x=r.*cos(t);y=r.*sin(t);z=t;plot3(x,y,z,'h','linewidth',2);gridonaxis('square')xlabel('x轴');ylabel('y轴');zlabel('z轴');title('圆柱螺旋线') 二、旋转抛物面b=0:0.2:2*pi;[X,Y]=meshgrid(-6:0.1:6);Z=(X.^2+Y.^2)./4;meshc(X
4、,Y,Z);axis('square')xlabel('x轴');ylabel('y轴');zlabel('z轴');title('旋转抛物面')或直接用:ezsurfc('(X.^2+Y.^2)./4') 三、椭圆柱面loadclownezsurf('(2*cos(u))','4*sin(u)','v',[0,2*pi,0,2*pi])view(-105,40) %视角处理shadinginterp %灯光处理colormap(map) %颜色处理gridon %添加网
5、格线axisequal %使x,y轴比例一致xlabel('x轴');ylabel('y轴');zlabel('z轴'); %添加坐标轴说明title('椭圆柱面') %添加标题四、椭圆抛物面b=0:0.2:2*pi;[X,Y]=meshgrid(-6:0.1:6);Z=X.^2./9+Y.^2./4;meshc(X,Y,Z);axis('square')xlabel('x轴');ylabel('y轴');zlabel('z轴');title('椭圆抛物面')或直接用:ezsurfc('X.^2./
6、9+Y.^2./4')五、'双叶双曲面ezsurf('8*tan(u)*cos(v)','8.*tan(u)*sin(v)','2.*sec(u)',[-pi./2,3*pi./2,0,2*pi])axisequalgridonaxissquarexlabel('x轴');ylabel('y轴');zlabel('z轴');title('双叶双曲面')六、双曲柱面loadclownezsurf('2*sec(u)','2*tan(u)','v',[-pi/2,pi/2,-3*pi,3*pi])holdon %在原来的图上继续作图ezsurf('2*sec(
7、u)','2*tan(u)','v',[pi/2,3*pi/2,-3*pi,3*pi])colormap(map)shadinginterpview(-15,30)axisequalgridonaxisequalxlabel('x轴');ylabel('y轴');zlabel('z轴');title('双曲柱面')七、双曲抛物面(马鞍面)[X,Y]=meshgrid(-7:0.1:7);Z=X.^2./8-Y.^2./6;meshc(X,Y,Z);view(85,20)axis(