To get a surf plot
조회 수: 2 (최근 30일)
이전 댓글 표시
I am a newbie, please also tell how to get a 'surf plot'. I am using MATLAB 2013, plots are shown inactive with the comment 'no variable selected'.
댓글 수: 0
채택된 답변
Walter Roberson
2015년 7월 16일
Example:
data = rand(40,60);
surf(data)
댓글 수: 4
Walter Roberson
2015년 7월 16일
surface plots can only be created for 2 dimension arrays of data. The coordinates can represent a rectangular grid or they can represent 2D parametric coordinates, but either way a surface can only be generated for a triple of data, (x,y,z) .
When you have a surface of n variables, then you have n input values and 1 result value, and you need an (n+1) dimensional output.
MATLAB only has plotting routines up to 3 dimensions -- so 2 input coordinates plus one result.
If you have more input coordinates then you can encode one coordinate as color using the C parameter of surf()
surf(X, Y, Z, C)
It is common to be able to create a "reasonable" surface of 3 inputs and one result (n = 3) this way.
To go beyond to n = 4 or more, you need to find ways to encode the extra dimensions. That can get difficult.
If you use scatter3() then you can encode one dimension as marker size, S
scatter3(X, Y, Z, S, C)
You can also encode information in the marker shape, but you need one plotting call for each different marker shape and there are only a small number of different marker shapes. Marker shapes also do not have any natural ordering, so it is difficult to convey distance using shape.
Information can also be encoded in transparency (Alpha) but it can be difficult to interpret.
The practical maximum is 4 inputs and one outputs, using scatter3 with X, Y, Z and marker size as inputs, and using color for the output. This will not look much like a surface, though. For surfaces, you might end up using X, Y and color for inputs and using Z for the output; I don't know how well that might work. X, Y, Z as inputs and colour for the output is common for drawing things like maps on a sphere and can be effective, but it would not typically be considered a surface plot.
The MATLAB plot routines will automatically determine the coordinate range for label purposes according to the data you plot.
Brendan Hamm
2015년 7월 17일
Just to follow up on this point, there is a function glyphplot in the Statistics and Machine Learning Toolbox which allows for the visualization of up to 17-dimensions. However, this will most certainly not be a surface.
추가 답변 (1개)
Ellison Castro
2015년 7월 16일
The 'surf' function is plotting function; it plots your data onto a graph. You should a set of data to be plotted.
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!