Plot A Cube Diagram Using Matlab

This article discusses how to plot a cube using Matlab.

Here is a final effect displayed as following.

We use the function ‘patch’ to draw the cube.

‘Faces’ represents all faces defined by faceLevel that we want to draw, it is composed of the relationship of the points mapped in the vertices set cubeLevel.

‘Vertices’ is an array with the dimension of  \(m \times 3\), where m is the number of vertices and each raw denote its coordinate [x,y,z].

For example, we have four points cubeLevel=[0 0 0; 1 0 0; 1 0 1; 0 0 1], we could draw a rectangle on x-z plain by setting faceLevel = [1 2 3 4] .

‘FaceVertexCData’ define the color we want to draw for the face. See more details in the Matlab official document.


邮箱地址不会被公开。 必填项已用*标注