1、 离散数据可视化实验:绘制离散函数 的图形,其中自变量的取值范围是(0,16)的整数
x=1:1:16
y=1./((x-3).^2+1)+1./((x-9).^2+4)
plot(x,y,'*')
Sep 21, 2018 10:52
(liyukun)
2、 二维曲线绘制实验:设计实验演示验证plot、subplot、axis、set、legend、xlabel、ylabel、zlabel、title、text、grid、box、hold、plotyy等函数在绘制二维曲线中的功能和使用方法。
plot(x,y,'*')
subplot(2,1,1)
plot(x,y)
subplot(2,1,2)
plot(x,2*y)
axis([0 4 0 20])
ss=plot(x,y)
set(gca,'color','g');设置颜色
grid on;网格
box on;边框
title('matlab实验');标题
xlabel('这是x');x轴
ylabel('这是y')
text(6,0.5,'这是(6,0.5)');图中显示文字
legend('y1');图例
hold on/hold off;新画的图是否覆盖原图
poltyy(不推荐)使用两个y轴创建图形plotyy(X1,Y1,X2,Y2)
Sep 21, 2018 11:06
(liyukun)
3、 三维曲线绘制实验:设计实验演示验证plot3、mesh、surf、fplot等函数在绘制三维曲线、曲面中的功能和使用方法。
Plot3(x,y,x+y);3维线图
[x,y]=meshgrid(-6:0.1:6);生成x,y二维数组
mesh(x,y,x+y);3维图
Sep 21, 2018 11:52
(liyukun)
Fplot(@(x)sin(x))
surf(x,y,x+y)
Sep 21, 2018 11:52
(liyukun)
4、 统计图绘制实验:设计实验演示验证面域图(area)、直方图(bar、barh、bar3、bar3h)、饼图(pie、pie3)、散点图(scatter、scatter3、plotmatrix)等统计图的绘制方法。
1.
x=1:1:16
y=1./((x-3).^2+1)+1./((x-9).^2+4)
y2=[y;y*2;y*3]
CC=flipud(cumsum(y2))
area(x',y2',0)
2.
subplot(2,2,1)
bar(x',y2','stacked')
subplot(2,2,2)
bar3h(x',y2','grouped')
subplot(2,2,4)
bar3(x',y2','stacked')
subplot(2,2,3)
barh(x',y2','grouped')
3.
subplot(1,2,1)
pie(x,y)
subplot(1,2,2)
pie3(x,y)
4.
subplot(2,2,1)
scatter(x,y)
subplot(2,2,2)
scatter3(x,y,x+y)
subplot(2,2,3)
plotmatrix(x)
subplot(2,2,4)
q=randn(100,2)
plotmatrix(q)
Sep 21, 2018 12:33
(liyukun)
5.
5、 三维图形编辑(精细控制)实验:设计实验演示验证用view、rotate、colordef、colormap、shading、light、lighting、material、surfl等函数对三维图形进行精细控制的方法。
1.
x=[1:1:10]
xx=[x;x*2;x*3;x*5;x*5;x*3;x*3;x*2;x;x]
surfl(xx)
2.
subplot(1,2,1)
surf(xx)
subplot(1,2,2)
hh=surf(xx)
rotate(hh,[-2,-2,0],10,[2,2,0])
3.
h=surf(xx)
view(0,40)
4.
colordef white
colormap jet
shading interp
5.
lighting flat
light('Position',[-1 0 0],'
lighting选择用于计算light对象对当前轴中所有对象surface和patch对象的影响的算法。但是,为了使lighting命令具有任何效果,必须使用该light函数创建照明对象。
lighting flat在物体的每个面上产生均匀的照明。选择此方法可查看多面体对象。
lighting gouraud计算顶点法线并在面上线性插值。选择此方法可查看曲面。
lighting none 关灯。
lighting(ax,...)使用由ax 当前轴指定的轴而不是当前轴。
light在当前轴上创建一个灯。灯光仅影响补丁和曲面对象。
light('PropertyName',propertyvalue,...)Light使用指定属性的指定值创建对象。有关属性的说明,请参见灯光属性。在MATLAB ®软件父母的光,以当前坐标,除非你指定与其它轴Parent属性。
light(ax,...)在指定的轴上ax而不是在当前轴(gca)中创建光。该选项ax可以在先前语法中的任何输入参数组合之前。
handle = light(...)返回Light创建的对象。https://www.mathworks.com
Sep 21, 2018 12:35
(liyukun)
6、 动画绘制实验:设计实验演示验证getframe与movie相结合绘制动画的方法。
surfl(xx)绘制(带光)
axis vis3d off 关闭坐标显示
axis equal 三维等比例
shading interp 影子美化
for(i=1:360)
view(-30+i,30)
m(i)=getframe
end
cla
movie(m)