MATLAB Drawing series of advanced drawing original address:http://blog.163.com/enjoy_world/blog/static/115033832007865616218/
Matlab drawing 2007-09-06 17:06:16 reading 4510 comments Ten font size: big medium small
First, Directory
1. Comet map
Two-dimensional comet map
Three-dimensional comet map
2. Frame animation
3. Program Animation
4. Color Map Transform
5.Voronoi graphs and triangulation
Voronoi Chart
Triangular split
6. Tetrahedron
7. Ribbon Chart
Ribbon Chart
Three-dimensional flow ribbon diagram
8. Pseudo-Color map
9. Slice diagram
Slice chart
Slice Contour Plot
10. Contour Diagram
Show Contour Lines
Show Apron
Waterfall effect
Shadow map with light mode
11. Function drawing
Contour, grid, surface, contour grid
Contour surfaces, two-dimensional curves, polar graphs, custom functions
12. Three-dimensional graphics control
Viewpoint
Lighting effects
Color control
Second, graphic example
1. Comet map
Two-dimensional comet map
T=0:.01:2*pi;
X=cos (2*t). * (cos (t). ^2);
Y=sin (2*t). * (Sin (t). ^2);
Comet (x, y);
Title (' Two-dimensional comet trajectory map ')
On
Plot (x, y)
Three-dimensional comet map
a=12;
b=9;
T0=2*pi;%t0 is the cycle of the orbit
T=5*t0;
dt=pi/100;
T=[0:dt:t] ';
F=SQRT (a^2-b^2);% the distance of the Earth from another focus
th=12.5*pi/180;% without the inclination of the orbit and the X-y plane
E=exp (-T/20);% orbital shrinkage rate
X=e.* (A*cos (t)-f);
y=e.* (b*cos (TH) *sin (t));
z=e.* (b*sin (TH) *sin (t));
PLOT3 (x, y, Z, ' G ')% draw full rail line
Hold On,sphere (20);% Draw the Earth
Axis off
Title (' Satellite Return to earth example ')
X1=-18*t0;
X2=6*t0;
Y1=-12*t0;
Y2=12*t0;
Z1=-6*t0;
Z2=6*t0;
Axis ([x1 x2 y1 y2 Z1 Z2])
% axis ([-15 10-15 10-10 10])
Axis equal
Comet3 (x,y,z,0.02);% Draw Movement rail line
Hold off
2. Frame animation
Z=peaks;
Surf (Z)% draw mesh surface map
Axis Tight
Set (GCA, ' nextplot ', ' replacechildren ');% set axis overlay Redraw mode
Title (' Frame animation playback example ')
For j=1:20
Surf (sin (2*pi*j/20) *z,z)% redraw the mesh surface, followed by a Z as the color matrix
F (j) =getframe;% Create frame
End
Movie (f,20)% play animation 20 times
3. Program Animations
T=0:pi/50:10*pi
I=1;
H=plot3 (sin (t (i)), cos (t (i)), T (i), ' * ', ' erasemode ', ' none '),% set Erase mode
Grid on
Axis ([-2 2-2 2-1 10*pi])
Title (' Program Animation example ')
For I=2:length (t)
Set (H, ' xdata ', sin (t (i)), ' Ydata ', cos (t (i)), ' Zdata ', T (i));
Drawnow
Pause (0.01)
End
4. Color Map Transformation
Load Spine
Image (X)
ColorMap Cool
Spinmap (10)
5. Voronoi graphs and triangulation
Voronoi Chart
Rand (' state ', 5)
X=rand (1,10);
Y=rand (1,10);
Subplot (131)
Voronoi (x, y);% Draw Voronoi graphics
Axis equal
Axis ([-0.2 1.6-0.5 2.5])
Subplot (132)
[Vx,vy]=voronoi (x, y);
Plot (x, y, ' r+ ', Vx,vy, ' B-');% apply return value draw
Axis equal
Axis ([-0.2 1.6-0.5 2.5])
Subplot (133)
Rand (' state ', 5);
X=rand (10,2);
[V,c]=voronoin (x);% return value v parameter dimension voronoi vertex matrix, return value c parameter is Voronoi cell array
For I=1:length (c)
If all (C{i}~=1)
Patch (V (c{i},1), V (c{i},2), i);% Applied Color Map I
End
End
Axis equal
Axis ([-0.2 1.6-0.5 2.5])
box on
Triangular split
[X,y]=meshgrid (1:15,1:15);
Tri=delaunay (x, y);
Z=peaks (15);
Trimesh (Tri,x,y,z)
6. Tetrahedron
D=[-1 1];
[X,y,z]=meshgrid (d,d,d);% defines a cube
X=[x (:); 0];
Y=[y (:); 0];
Z=[z (:); 0];%[x,y,z] Add the center of the cube vertices respectively
X=[x (:) y (:) z (:)];
Tes=delaunayn (X);% returns the array value of MXN
Tetramesh (tes,x);% plot tetrahedral plots
Camorbit (20,0);% rotating camera target position
7. Ribbon Chart
Ribbon Chart
[X,y]=meshgrid ( -3:.5:3,-3:.1:3);
Z=peaks (x, y);
Ribbon (Y,Z)
Three-dimensional flow ribbon diagram
Load wind% to open saved data
lims=[100.64 116.67 17.25 28.75-0.02 6.86];% defining the axis range
[X,y,z,u,v,w]=subvolume (X,y,z,u,v,w,lims);%lims to define a subset of data
[SX sy Sz]=meshgrid (110,20:5:30,1:5);% definition grid point
VERTS=STREAM3 (x,y,z,u,v,w,sx,sy,sz,.5);% compute ribbon vertices
Cav=curl (x,y,z,u,v,w);% calculation of crimp angular velocity
WIND_SPEED=SQRT (u.^2+v.^2+w.^2);% calculated flow rate
H=streamribbon (verts,x,y,z,cav,wind_speed,2);% Draw Stream Ribbon graph
View (3)
8. Pseudo Color Map
n=6% defining the number of wheels
R= (0:n) '/n;% defines the radius of the wheel
theta=pi* (-n:n)/n;% defining the sector angle of the wheel
X=r*cos (theta);
Y=r*sin (theta);% definition mesh vertex
C=r*cos (2*theta);% Definition Color map
Pcolor (x,y,c)% plot pseudo-color chart axis equal tight
9. Slice chart
Slice chart
[x, Y, z] = Meshgrid ( -2:.2:2,-2:.25:2,-2:.16:2);
v = x.*exp (-x.^2-y.^2-z.^2);
Xslice = [ -1.2,.8,2]; Yslice = 2; Zslice = [ -2,0];
Slice (X,y,z,v,xslice,yslice,zslice)
ColorMap HSV
Slice Contour Plot
[x y z v]=flow;% open Flow data
H=contourslice (X,y,z,v,[1:9],[],[0],linspace ( -8,2,10));% Slice Contour Line
View ([-12 30])
10. Contour Map
Show Contour Lines
[X,y,z]=peaks;
Subplot (1,2,1)
MESHC (x, y, z);% also plots grid and contour lines
Title (' MESHC grid chart and Contour line ')
Axis ([-inf inf-inf inf-inf inf]);
Subplot (1,2,2)
SURFC (x, y, z);% simultaneously draws the surface plot and the contour line
Title (' Surfc surface chart and Contour line ')
Axis ([-inf inf-inf inf-inf inf]);
Show Apron
[x y z]=peaks;
Meshz (x, y, z);
Waterfall effect
[X,y,z]=peaks (30);
Waterfall (x, y, z)
Shadow map with light mode
[X,y]=meshgrid ( -3:1/8:3);
Z=peaks (x, y);
SURFL (x, y, z);
Shading interp% Coloring Treatment
ColorMap (gray);% grayscale processing
Axis ([-3 3-3 3-8 8])
11. function drawing
Contour, grid, surface, contour grid
% Figure 1 plot contour, grid, surface, contour grid
Subplot (221)
f=[' 1-x ' ^2*exp (-(x^2)-(y+1) ^2) -10* (x/5-x^3-y^5) *exp (-x^2-y^2) -1/3*exp (-(x+1) ^2-y^2) '];% define the function of Bivariate x, y
Ezcontour (f,[-3,3],49)%x, y is [-3 3], grid is 49x49
Subplot (222)
Ezmesh (' sqrt (x^2+y^2) ');
Subplot (223)
Ezsurf (' Real (Atan (x+i*y)) ')% filtered if the same data surf the drawing without filtering
Subplot (224)
EZMESHC (' y/(1+x^2+y^2) ', [ -5,5,-2*pi,2*pi])%x, y values range from [-5 5], [ -2*pi 2*PI]
Contour surfaces, two-dimensional curves, polar graphs, custom functions
% Figure 2 Drawing contour surface, two-dimensional curve, polar graph, custom function
Figure (2)
Subplot (221)
Ezsurfc (' Sin (u) *sin (v) ')
Subplot (222)
Ezplot (' x^2-y^4 ');
Subplot (223)
Ezpolar (' 1+cos (t) ')
Subplot (224)
Fplot (' Myfun ', [-20 20])
function Y=myfun (x)
Y (:, 1) =200*sin (x (:))./x (:);
Y (:, 2) =x (:). ^2;
Three-dimensional curve
% draw three-dimensional graphs
Figure (3)
Ezplot3 (' sin (t) ', ' cos (t) ', ' t ', [0,6*PI])
12. Three-dimensional graphics control
Viewpoint
View
Graphics rotation
Subplot (121)
Surf (peaks);
Title (' Pre-rotation graph ');
Subplot (122)
H=surf (peaks);
Rotate (h,[1 0 1],180)
Title (' rotated graphic ');
Lighting effects
% lighting effect (1) camlight (2) Light (3) Lightangle (4) Lighting (5) Material
Sphere
Camlight
Color control
% Color Control (1) default settings Colordef, WHITEBG (2) color map ColorMap (3) Shading processing shading
Load Flujet
Image (X)
ColorMap (Jet)
Subplot (131)
Sphere (16)
Axis Square
Shading Flat
Title (' Flat shading ')
Subplot (132)
Sphere (16)
Axis Square
Shading Faceted
Title (' Faceted shading ')
Subplot (133)
Sphere (16)
Axis Square
Shading Interp
Title (' interpolated shading ')
Advanced drawing of MATLAB drawing series