matlab基础——LinePlots and Subplots

来源:互联网 发布:和平电视直播软件 编辑:程序博客网 时间:2024/06/15 22:24
%%%%%Line Plots%%%%%%%To creat two-dimensional line plots,use the plot functionx=linspace(0,2*pi);%To generate linearly spaced vector,use the linspace functiony=sin(x);z=cos(x);figureplot(x,y);xlabel('x');%label the axesylabel('y');title('y=sin(x)');%add a titlefigureplot(x,z,'r-s');%plot(X,Y,LineSpec) sets the line style, marker symbol, and color                %如此处设置线条为红色(r)实线(-)方块(s),详见matlab帮助文档figureplot(x,y,x,z);legend('sin','cos');%Add legend to graph%%%%%Subplots%%%%%%%display multiple plots in different subregions of the same window using the subplot function %the first two inputs to subplot indicate the number of plots in each row  and column%the third input specifies which plot is activefiguresubplot(2,2,1);plot(x,y);xlabel('x');ylabel('y');title('one');subplot(2,2,2);plot(x,z,'r--');xlabel('x');ylabel('y');title('two');subplot(2,2,3);plot(x,y,x,z);xlabel('x');title('three');

运行结果:


原创粉丝点击