MatLab图形绘制2.docVIP

  • 7
  • 0
  • 约6.65千字
  • 约 29页
  • 2017-08-02 发布于河南
  • 举报
第二讲 MatLab图形绘制 1.绘制x-y平面坐标图 x=linspace(0,2*pi,30) y=sin(x); z=cos(x); a=2*sin(x).*cos(x); b=sin(x)./(cos(x)+eps); subplot(2,2,1) plot(x,y),axis([0 2*pi -1 1]),title(sin(x)); subplot(2,2,2); plot(x,z),axis([0 2*pi -1 1]),title(cos(x)) subplot(2,2,3) plot(x,a) title(2sin(x)cos(x)) axis([0 2*pi -1 1]) subplot(2,2,4) plot(x,b) axis([0 2*pi -20 20]) title(sin(x)/cos(x)) 2.1 x=linspace(0,2*pi,30); y=sin(x); z=cos(x); plot(x,y,x,z); grid; xlabel(自变量x); %x轴标注 ylabel(自变量y和z); %y轴标注 title(sine和cosine图); %添加标题 text(2.5,0.7,sin(x)); gtext(cos(x)) 2.2 x=linspace(23.1,98.7,11); datal1=[0.00 1.23 4.68 7.97 5.63 2.82 6.57 11.32 8.97 5.73 7.94]; plot(x,datal,r--+) datal2=[3.21 6.35 8.97 4.59 6.89 5.23 1.58 7.32 1.95 8.32 4.98]; hold on plot(x,datal2,b:p) legend(datal1,datal2,4) title(数据折线图) xlabel(自变量x); ylabel(自变量y和z); 3.极坐标绘制 t=0:0.01:2*pi; r=sin(2*t).*cos(2*t); polar(t,r),gtext(polar plot of sin(2t)cos(2t)); 3a.绘制形如f(x,y)=0的隐函数图像 ezplot(x^4+y^4-18*(x^2+y^2)+14=0) 3b.ezplot函数绘制显函数图 ezplot(exp(-3*t)*sin(4*t+2)+4*exp(-0.5*t)*cos(2*t)-0.5,[0 5]) 3c.已知f(x),a求f(a) syms x fx=x^5-sqrt(x); a=89.7; subs(fx,a) ######################################### syms x y; subs(x*y, {x, y}, {[0 1; -1 0], [1 -1; -2 1]}) ans = 0 -1 2 0 3c. theta=-pi/2:0.01:3*pi/2; polar(theta,100./(100+(theta-pi/2).^8).*(2-sin(7*theta)-cos(30*theta/2))); 4.绘制直方图 x=-2.9:0.2:2.9; y=exp(-x.*x); bar(x,y); 5.绘制梯形图 x=-2.9:0.2:2.9; y=exp(-x.*x); stairs(x,y); 6.绘制单变量函数曲线 (1) y=sym(1-exp(-x)*sin(x)); ezplot(y,[0,20]) axis([0 20 0.65 1.1])%调整坐标的轴范围 (2) fplot(sin(3*x),[0,pi]) figure fplot([sin(x),cos(x)],[-2*pi,2*pi]); (3)绘制彗星(动态参数)图 t=0:pi/30:2*pi; x=exp(sin(2*t)).*(cos(t).^2/3); y=t.*(sin(t).^2); comet(x,y) 7.1添加注释 x=0:0.1:2*pi; plot(x,sin(x),r-.) hold on plot(x,cos(x),b:o) axis equal %横纵坐标采用等长刻度 legend(sin(x),cos(x),4) %加一个小方框注释分别两个函数,4表示右下角 text(pi,sin(pi),x=\pi\nu\delta\Gamma)% \pi\nu\delta\Gamma分别对

文档评论(0)

1亿VIP精品文档

相关文档