查看完整版本 : 【求助】patch命令
patch命令可以绘制云图。
从参考书上见一例子:
colormap('default');
x=[0;1;0.5];
y=[0;0;0.866];
c=[-5;5;0];
patch(x,y,c)
其中c给定了三个角点的颜色值,这点就不明白了。望高手们指教!!!谢谢
请仔细参阅matlab中的help文档,其中讲得非常详细……^_^
x,y定义的是顶角坐标,c定义的是颜色
请仔细参阅matlab中的help文档,其中讲得非常详细……^_^
x,y定义的是顶角坐标,c定义的是颜色
PATCH(X,Y,C) adds the "patch" or filled 2-D polygon defined by
vectors X and Y to the current axes. If X and Y are matrices of
the same size, one polygon ("face") per column is added. C
specifies the color of the face(s) ("flat" coloring), or the
vertices ("interpolated" coloring), for which bilinear interpolation
is used to determine the interior color of the polygon.
For both vector or matrix X and Y, if C is a string, each face
is filled with 'color'. 'color' can be 'r','g','b','c','m','y',
'w', or 'k'. If C is a scalar it specifies the color of the
face(s) by indexing into the colormap. A 1x3 vector C is always
assumed to be an RGB triplet specifying a color directly.
For vector X and Y, if C is a vector of the same length, it
specifies the color of each vertex as indices into the
colormap and bilinear interpolation is used to determine the
interior color of the polygon ("interpolated" shading).
When X and Y are matrices, if C is a 1xn, where n is the number
of columns in X and Y, then each face j=1:n is flat colored by the
colormap index C(j). Note the special case of a 1x3 C is always
assumed to be an RGB triplet ColorSpec and specifies the same
flat color for each face. If C is a matrix the same size as X
and Y, then it specifies the colors at the vertices as colormap
indices and bilinear interpolation is used to color the faces.
If C is 1xnx3, where n is the number of columns of X and Y,
then each face j is flat colored by the RGB triplet C(1,j,:).
If C is mxnx3, where X and Y are mxn, then each vertex
(X(i,j),Y(i,j)) is colored by the RGB triplet C(i,j,:) and the
face is colored using interpolation.
这是help中的解释,恕我愚钝,我仍然不能理解c中的数值是什么含义,颜色代号?谢谢版主的热心解答,麻烦你更详细的解释下吧,非常感谢!!
首先说明一下RGB的意思:
RGB=Red Green Blue
任何颜色都是这三种颜色的组合,因此这三种颜色称为原色,每种颜色表示范围是从0~255。
在计算机图像中,计算机用这三种颜色的组合表示颜色,但真正显示的却是像素,这个这里就不多讲了。
上面的patch命令是绘制多角图形,向量x,y中的每一对对应的点都代表这个多角形的顶点的坐标,而对应于向量c中的值就代表这个顶点坐标的颜色值,然后利用插值,将不同的每个顶点的颜色进行过渡。
比如上面的程序中,三角形最上方的顶点对应的颜色0,两个边角对应的颜色分别为-5和5,从而利用插值先从-5过渡到0,然后再从0过渡到5。
具体的算法是怎么样的,我也搞不大懂,令我很迷惑的就是为什么这么组合的时候,会产生一个颜色的谱图,而用单色显示的时候,比如说用下面的命令:
patch(x,y,5)
图片却是青色的,和下面的命令:
patch(x,y,0)
显示的颜色是一样的,而有时候却不一样,呵呵,上面就是我的解释,有用则采之……
首先说明一下RGB的意思:
RGB=Red Green Blue
任何颜色都是这三种颜色的组合,因此这三种颜色称为原色,每种颜色表示范围是从0~255。
在计算机图像中,计算机用这三种颜色的组合表示颜色,但真正显示的却是像素,这个这里就不多讲了。
上面的patch命令是绘制多角图形,向量x,...
very very thank dnping!!
让我又有点明白了,:)
但是对于数值的具体含义还是迷糊的。
对于数值问题我现在也有点迷糊,因为对于matlab而言,RGB的范围是从0~255,而上面的程序是从-5~5,好像matlab是用的这样的算法:
-5处对应的颜色和5对应的颜色是一样的,也就是说,在-255~0范围内的颜色和在0~255内产生的颜色是一致的。
并且对于我的疑问,可能是由于0~255范围太大,用5来表示的颜色和0表示的颜色用肉眼判别不出来。
你如果用如下命令:
patch(x,y,0);
patch(x,y,10);
patch(x,y,20);
patch(x,y,30);
patch(x,y,40);
patch(x,y,50);
patch(x,y,70);
patch(x,y,100);
……
patch(x,y,200);
patch(x,y,255);
比较以上产生的图像的颜色,我们就可以明显感到了颜色的变化。
为什么
c=[-5;0;5]
就可以产生那些颜色变化,而且恰好是从-255--->0--->255,整个颜色范围都变化到了,我也不大明白。
呵呵,需要明白人讲一下算法了……
感谢版主的解答,我暂时放弃对数值的具体研究,而是将应力值代入c中;对其颜色的变化还在研究中,望有明白的朋友解释解释!!!
vBulletin® v3.8.3,版权所有 ©2000-2025,Jelsoft Enterprises Ltd.