使用Matlab进行基本绘图

 时间:2024-10-16 18:30:38

Matlab常用与科学计算和分析,其中Matlab内置的图形绘制功能也是相当的强大。本例分享使用Matlab的基本绘图功能。

工具/原料

Matlab

plot绘制二维图形

1、使用plot函数绘制正弦曲线。x轴:x=0:pi/10:2*pi;设置x轴为0到2pi的范围,y:y=sin(x),绘图:plot(x,y);

使用Matlab进行基本绘图

2、使用xlabel,ylabel,legend等对图形即兴进一步的解释处理。>> xlab髫潋啜缅el('x轴')>> ylabel('y轴')>> legend('y=sin(x)')>> title('正弦曲线图')

使用Matlab进行基本绘图

plot3,mesh,surf,surfc绘制三维图

1、plot3 Plot lines and points in 3-D space. plot3() is a three-dimensional analogue of PLOT(). plot3(x,y,z), where x, y and z are three vectors of the same length, plots a line in 3-space through the points whose coordinates are the elements of x, y and z. plot3(X,Y,Z), where X, Y and Z are three matrices of the same size, plots several lines obtained from the columns of X, Y and Z. Various line types, plot symbols and colors may be obtained with plot3(X,Y,Z,s) where s is a 1, 2 or 3 character string made from the characters listed under the PLOT command. plot3(x1,y1,z1,s1,x2,y2,z2,s2,x3,y3,z3,s3,...) combines the plots defined by the (x,y,z,s) fourtuples, where the x's, y's and z's are vectors or matrices and the s's are strings.

2、plot3示例:t=0:pi/50:6*pi;plot3(t.*sin(3*t),t.*cos(3*t),t)grid

使用Matlab进行基本绘图

3、三维网格图:mesh;[X,Y] = meshgrid(-8:.5:8);R = sqrt(X.^2 + Y.^2) + eps;Z = sin(R)./R;mesh(Z);

使用Matlab进行基本绘图

4、surf函数:k = 5;n = 2^k-1;[x,y,z] = sphere(n);c = hadamard(2^k);surf(x,y,z,c);colormap([1 1 0; 0 1 1])axis equal

使用Matlab进行基本绘图

5、surfc:> [X,Y,Z] = peaks(30);surfc(X,Y,Z)colormap hsvaxis([-3 3 -3 3 -10 5])

使用Matlab进行基本绘图

bar,barh绘制条形图

1、bar:y = [75.995 91.972 105.711 123.203 131.669 ... 150.697 179.323 203.212 226.505 249.633 281.422];figure; bar(y);

使用Matlab进行基本绘图

2、barh:y = [75.995 91.972 105.711 123.203 131.669 ... 150.鲂番黟谊697 179.323 203.212 226.505 249.633 281.422];figure; barh(y);

使用Matlab进行基本绘图

area区域图

1、area:Y = [1, 5, 3;3, 2, 7;1, 5, 3;2, 6, 1];area(Y)grid oncolormap summerset(gca,'Layer','top')title 'Stacked Area Plot'

使用Matlab进行基本绘图

pie函数绘制饼图

1、x = [1 3 0.5 2.5 2];explode = [0 1 0 0 0];pie(x,explode)colormap jet

使用Matlab进行基本绘图

hist,rose等函数绘制直方图

1、x = -4:0.1:4;y = randn(10000,1);hist(y,x)

使用Matlab进行基本绘图

2、rose:figureload sunspot.dat % Contains a 2-column vector named sunspotrose(sunspot(:,2),12)

使用Matlab进行基本绘图
  • 如何在matlab中设置现有对象的属性?
  • MATLAB如何在直角坐标下描绘曲线图
  • Matlab中如何使用linspace?
  • Matlab中同一张图中不同类型数据的图例绘制
  • matlab中ln函数怎么表示
  • 热门搜索
    感恩手抄报资料 清明节手抄报简单画 我爱文学手抄报内容 地球日手抄报的文字 九九重阳节手抄报大全 手抄报装饰小图案 安全手抄报版面设计 缅怀先烈的手抄报图片 国家公祭日手抄报 保护海洋手抄报