Matlab Tutorials —— "surf"

"Plot" function is used to draw lines. When it comes to surfaces, we need "surf".


Here gives an example:

% Start
theta = linspace(0, 10*pi, 100);
c = cos(theta/5);
z = c' * c;


figure(1);
surf(z); % create a surface using data from z and their x, y axes will follow the matrix coordinate of z


figure(2);
surf(theta, theta, z); % create a surface using data from z with given x, y axes
colorbar; % add colorbar to show how colors represent numbers


figure(3);
surf(z, ... % some propeties of a surface 
    'FaceAlpha', 0.8, ... % Transparency
    'FaceColor', 'interp', ... % Face color style
    'EdgeColor', 'none', ... % Edge color,'none' means no edge.
    'LineStyle', ':' ... % line style, but it's actually useless here since there is no edge
    );
    


Appendix may be needed:

Edge line color, specified as one of the values listed here.The default color of [0 0 0] corresponds to blackedges.

ValueDescription
'none'Do not draw the edges.
'flat'

Use a different color for each edge based on the valuesin the CData property. First you must specifythe CData property as a matrix the same size as ZData.The color value at the first vertex of each face (in the positive x and y directions)determines the color for the adjacent edges. You cannot use this valuewhen the EdgeAlpha property is set to 'interp'.

'interp'

Use interpolated coloring for each edge based on the values in the CData property. First you must specify the CData property as a matrix the same size as ZData. The color varies across each edge by linearly interpolating the color values at the vertices. You cannot use this value when the EdgeAlpha property is set to 'flat'.

RGB triplet or color name

Use the specified color for all the edges. This option does not use the color values in the CData property.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7]. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.

OptionDescriptionEquivalent RGB Triplet
'red' or 'r'Red[1 0 0]
'green' or 'g'Green[0 1 0]
'blue' or 'b'Blue[0 0 1]
'yellow' or 'y'Yellow[1 1 0]
'magenta' or 'm'Magenta[1 0 1]
'cyan' or 'c'Cyan[0 1 1]
'white' or 'w'White[1 1 1]
'black' or 'k'Black[0 0 0]

'LineStyle'Line style
'-' (default) | '--' | ':' | '-.' | 'none'

Line style, specified as one of the options listed in this table.

Line StyleDescriptionResulting Line
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'No lineNo line

'FaceColor'Face color

'flat' (default) | 'interp' | 'none' | 'texturemap' | RGB triplet | 'r' | 'g' | 'b' | ...

Face color, specified as one of the values in this table.

ValueDescription
'flat'

Use a different color for each face based on the valuesin the CData property. First you must specifythe CData property as a matrix the same size as ZData.The color value at the first vertex of each face (in the positive x and y directions)determines the color for the entire face. You cannot use this valuewhen the FaceAlpha property is set to 'interp'.

'interp'

Use interpolated coloring for each face based on the values in the CData property. First you must specify the CData property as a matrix the same size as ZData. The color varies across each face by interpolating the color values at the vertices. You cannot use this value when the FaceAlpha property is set to 'flat'.

RGB triplet or color name

Use the specified color for all the faces. This option does not use the color values in the CData property.

'texturemap'Transform the color data in CData so thatit conforms to the surface.
'none'Do not draw the faces.
阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页