本文为matlab自学笔记的一部分,之所以学习matlab是因为其真的是人工智能无论是神经网络还是智能计算中日常使用的,非常重要的软件。也许最近其带来的一些负面消息对国内各个高校和业界影响很大。但是我们作为技术人员,更是要奋发努力,拼搏上进,学好技术,才能师夷长技以制夷,为中华之崛起而读书!
本文很多摘录自图书资料,不做任何商业用途,仅做技术分享,侵权删除!请不要放弃自己的理想和道路,加油!!
“参考书籍 《matlab 程序设计与综合应用》张德丰等著 感谢张老师的书籍,让我领略到matlab的便捷 《MATLAB技术大全》葛超等编著 感谢葛老师的书籍,让我领略到matlab的高效
subplot(2,2,1);mesh(peaks);
view(-37.5,30);
subplot(2,2,2);mesh(peaks);
view(0,90);
title('azimuth=0,elevation=90')
subplot(2,2,3);mesh(peaks);
view(90,0);
title('azimuth=90,elevation=0')
subplot(2,2,4);mesh(peaks);
view(-7,-10);
title('azimuth=-7,elevation=-10')
shg;clf;
[X,Y]=meshgrid([-3:.2:3]);
Z=4*X.*exp(-X.^2-Y.^2);
G=gradient(Z);
subplot(1,2,1),surf(X,Y,Z,G)
subplot(1,2,2),h=surf(X,Y,Z,G)
rotate(h,[-2,-2,0],30,[2,2,0]),colormap(cool)
>> hot(8)
ans =
0.3333 0 0
0.6667 0 0
1.0000 0 0
1.0000 0.3333 0
1.0000 0.6667 0
1.0000 1.0000 0
1.0000 1.0000 0.5000
1.0000 1.0000 1.0000
n=20;
colormap(jet(n))% jet色图方式
pcolor([1:n+1;1:n+1]')
title(' Using Pcolor to Display a Color Map')
colormap(cool);
z=peaks(40);
subplot(2,2,1);
surf(z);
caxis([-2 2]);
colorbar;
z=peaks(40);
subplot(2,2,2);
surf(z);
caxis([-2 2]);
colorbar('vert');
z=peaks(40);
subplot(2,2,3);
surf(z);
caxis([-2 2]);
colorbar horiz;
z=peaks(40);
subplot(2,2,4);
surf(z);
caxis([-2 2]);
colorbar horiz
% 人为增加一个颜色的维度
[X,Y,Z] = sphere;
C = Z;surf(X,Y,Z,C)
caxis([-1 3])
[x,y,z]=sphere(30);
colormap(flag);
subplot(1,3,1);
surf(x,y,z);
axis equal
subplot(1,3,2);
surf(x,y,z);shading flat;
axis equal
subplot(1,3,3);
surf(x,y,z);shading interp;
axis equal
% 示例1:
figure(1);
[x,y,z]=peaks;
surf(x,y,z);
shading interp;
light('Color',[1 0 1],'Style','local','Position',[-4,-4,10])
% 示例2:
figure(2);
[X,Y,Z]=sphere(40);
colormap(jet)
subplot(1,2,1);surf(X,Y,Z);shading interp
light ('position',[0 -10 1.5],'style','infinite')
lighting phong
material shiny
subplot(1,2,2);surf(X,Y,Z,-Z);shading flat
light;lighting flat
light('position',[-1,-1,-2],'color','y')
light('position',[-1,0.5,1],'style','local','color','w')
% 示例三
figure(3);
[x,y,z]=peaks(20);
subplot(1,2,1);
surf(x,y,z)
shading interp;
material([0.2,0.3,0.6,10,0.4]);
light('color','r','position',[0 1 0],'style','local')
lighting phong
subplot(1,2,2);
surf(x,y,z)
shading flat;
material shiny;
light('color','w','position',[-1 0.5 1],'style','local')
lighting flat