Presentation is loading. Please wait.

Presentation is loading. Please wait.

Yang-Ming University, Taipei, Taiwan

Similar presentations


Presentation on theme: "Yang-Ming University, Taipei, Taiwan"— Presentation transcript:

1 Yang-Ming University, Taipei, Taiwan
Graphics II

2 Colormap

3 Color Map RGB Matrix of color map Red: 0~1 Green: 0~1 Blue: 0~1 R G B
0.5 1 RGB Red: 0~1 Green: 0~1 Blue: 0~1 Matrix of color map

4 Default cmaps help colormap Create a 20-level hot cmap gray jet hot
help colormap gray jet hot hsv …… Create a 20-level hot cmap hot(20) colormap(hot(20))

5 User-Defined Color Map
. . . col1=[zeros(20,1),zeros(20,1),linspace(0,1,20)']; col2=[zeros(20,1),linspace(0,1,20)',linspace(1,0,20)']; col3=[linspace(0,1,20)',linspace(1,0,20)',zeros(20,1)]; cmap=[col1;col2;col3]; colormap(cmap); colorbar . . . . . .

6 製作一從黑到紅,紅到黃,黃到綠的colormap,更換無尾熊 的色階為此colormap
(MATLAB會把執行結果顯示在command window上)

7 Graphics in 3-D

8 3-D Plot 3-D line plot Syntax plot3(X1,Y1,Z1,...,Xn,Yn,Zn)
t = 0:pi/50:10*pi; st = sin(t); ct = cos(t); figure; plot3(st,ct,t) hold on plot3(ct,st,t) grid on 3-D line plot Syntax plot3(X1,Y1,Z1,...,Xn,Yn,Zn) t = 0:pi/50:10*pi; st = sin(t); ct = cos(t); figure; plot3(st,ct,t)

9 3-D Plot by Specifying Line Style
Description - Solid line (default) -- Dashed line : Dotted line -. Dash-dot line Marker Description o Circle + Plus sign * Asterisk . Point x Cross s Square d Diamond ^ Upward-pointing triangle v Downward-pointing triangle > Right-pointing triangle < Left-pointing triangle p Pentagram h Hexagram Color Description y yellow m magenta c cyan r red g green b blue

10 3-D Plot – Specify Line Style
Syntax plot3(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn) ('CLM': color, line, marker) t = 0:pi/50:10*pi; st = sin(t); ct = cos(t); figure; plot3(st,ct,t,'r-')

11 3-D Plot – Change Properties of Line
plot3(...,'PropertyName',PropertyValue,...) Line properties Color LineStyle LineWidth Marker MarkderSize MarkerEdgeColor MarkerFaceColor …

12 3-D Plot – mesh Syntax mesh(X,Y,Z) mesh(Z) [X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps; Z = sin(R)./R; figure; mesh(Z)

13 3-D Plot – surf Surface plot Syntax surf(X,Y,Z) surf(X,Y,Z,C)
[X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X) + cos(Y); C = X.*Y; surf(X,Y,Z) colorbar surf(X,Y,Z,C) Surface plot Syntax surf(X,Y,Z) surf(X,Y,Z,C) The function plots the values in matrix Z as heights above a grid in the x-y plane defined by X and Y.

14 3-D Sphere Plot figure; sphere % Create a 20-by-20 faces sphere

15 3-D Sphere Plot [x,y,z] = sphere; figure; surf(x,y,z) hold on
surf(x+3,y-2,z) % centered at (3,-2,0) surf(x,y+1,z-3) % centered at (0,1,-3) [x,y,z] = sphere; figure; mesh(x,y,z)

16 3-D Plot – patch Create one or more filled polygons Syntax
patch(X,Y,C) patch(X,Y,Z,C) x = [2 5; 2 5; 8 8]; y = [4 0; 8 2; 4 0]; c = [0; 1]; figure; patch(x,y,c) colorbar

17 3-D Plot – patch figure; Pl_lat = patch('Faces', data.faces_l, 'Vertices', data.vertices_l, 'FaceColor', [ ], 'EdgeColor', 'none', 'Facealpha', 0.5); view(gca, -90,0); light(gca, 'Style', 'infinite', 'Position', [0 1 0]) set(Pl_lat, 'FaceLighting', 'gouraud'); light(gca, 'Style', 'infinite', 'Position', [0 -1 0]) light(gca, 'Style', 'infinite', 'Position', [-1 0 0]) set(gca, 'Color', [0 0 0])

18 在command window輸入“L = 160*membrane(1,100);” 使用“surface”畫圖 去除edgecolor
Create a matlab logo 在command window輸入“L = 160*membrane(1,100);” 使用“surface”畫圖 去除edgecolor 調整圖軸為X: [1 201], Y: [1 201], Z: [ ] 打兩道光:一為位置在[ ]顏色為[ ]的光, 另一為位置在[ ];顏色為[ ]的光 更改物體顏色為[ ] 更改背景顏色為黑色並將圖軸去除 (MATLAB會把執行結果顯示在command window上)

19 Thank you for your attention!!


Download ppt "Yang-Ming University, Taipei, Taiwan"

Similar presentations


Ads by Google