失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > matlab二维画图函数汇总--论文 数学建模中使用

matlab二维画图函数汇总--论文 数学建模中使用

时间:2022-12-02 08:52:34

相关推荐

matlab二维画图函数汇总--论文 数学建模中使用

一段代码对应相应的图形:

%matlab基本画图clcclearx = linspace(-2*pi,2*pi,100);y = sin(x);%画出基本线条plot(x,y);%画出多条曲线plot(x,sin(x),x,cos(x));

%根据矩阵画出线条clcclearY = magic(5)figureplot(Y)

%指定线形clcclearx = 0:pi/100:2*pi;y1 = sin(x);y2 = sin(x-0.25);y3 = sin(x-0.5);figureplot(x,y1,x,y2,'--',x,y3,':');

%指定线形颜色和标记clcclearx = 0:pi/10:2*pi;y1 = sin(x);y2 = sin(x-0.25);y3 = sin(x-0.5);figureplot(x,y1,'g',x,y2,'b--o',x,y3,'c*');

%在指定的数据点显示标记clcclearx = linspace(0,10);y = sin(x);plot(x,y,'-o','MarkerIndices',1:5:length(y));

%指定线宽,标记大小和标记颜色clcclearx = -pi:pi/10:pi;y = tan(sin(x)) - sin(tan(x));figureplot(x,y,'--gs',...'LineWidth',2,...'MarkerSize',10,...'MarkerEdgeColor','b',...'MarkerFaceColor',[0.5,0.5,0.5])

%添加标题和轴标签clcclearx = linspace(0,10,150);y = cos(5*x);figureplot(x,y,'Color',[0,0.7,0.9]);title('2-D Line Plot');xlabel('x');ylabel('cos(5x)');

%绘制持续时间并指定刻度格式clccleart = 0:seconds(30):minutes(3);y = rand(1,7);plot(t,y,'DurationTickFormat','mm:ss');

%指定线图的坐标区clcclearax1 = subplot(2,1,1);x = linspace(0,3);y1 = sin(5*x);plot(ax1,x,y1);title(ax1,'Top Subplot');ylabel(ax1,'sin(5x)');ax2 = subplot(2,1,2);y2 = sin(15*x);plot(ax2,x,y2);title(ax2,'Botton Subplot');ylabel(ax2,'sin(15x)');

%创建并修改线条clcclearx = linspace(-2*pi,2*pi)y1 = sin(x)y2 = cos(x)p = plot(x,y1,x,y2)p(1).LineWidth = 2p(2).Marker = '*'

%绘制图形clcclearr = 2;xc = 4;yc = 3;theta = linspace(0,2*pi);x =r*cos(theta)+xc;y =r*sin(theta)+yc;plot(x,y);axis equal

%其他画图函数%条形图clcclearclose allx = 1:10y = rand(size(x))bar(x,y)

%误差图clcclearclose allx = linspace(0,2*pi,30)y = sin(x)e = std(y)*ones(size(x))errorbar(x,y,e)%fplot用来画出剧烈变化的图形fplot(@(x)sin(1./x),[0.02,0.2]);

%极坐标图clcclose allcleartheta = linspace(0,2*pi)r = cos(4*theta)polarplot(theta,r)

clcclearx = randn(5000,1)histogram(x,20)

%rose类似于hist,表达形式不一样clcclearx = randn(1000,1)polarhistogram(x)

%stairs画出阶梯图clcclearx = linspace(0,10,50)y = sin(x).*exp(-x/3)stairs(x,y)

%stem画出针状图clcclearx = linspace(0,10,50)y = sin(x).*exp(-x/3)stem(x,y)

%fill多边形画图clcclearx = linspace(0,10,50)y = sin(x).*exp(-x/3)fill(x,y,'b')

%feather以复数画出数据clccleartheta = linspace(0,2*pi,20)z = cos(theta)+1i*sin(theta)feather(z)

%compass和feather类似,箭头起点在原点clccleartheta = linspace(0,2*pi,20)z = cos(theta)+1i*sin(theta)compass(z)

如果觉得《matlab二维画图函数汇总--论文 数学建模中使用》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。