# how to get RGB color?

조회 수: 4(최근 30일)
JMS 2014년 5월 9일
댓글: Oliver Woodford 2014년 5월 12일
How do I get RGB color? Or what I got using 'pcolor()' can be considered to be as RGB?
Vx = V_x1 + V_x2;
Vy = V_y1 + V_y2;
ang = atan2(Vy, Vx);
pcolor(x, y, ang);
hold on;

댓글을 달려면 로그인하십시오.

### 답변(2개)

Image Analyst 2014년 5월 9일
편집: Image Analyst 2014년 5월 9일
pcolor() does not return an RGB image. It displays one. If you display a matrix though, pcolor chops off one row and one column so you're better off using image(). I never use pcolor for displaying images for that reason. I don't really know what you're doing because you didn't attach a screenshot. If you have certain kinds of data that pcolor is meant for, it might be fine, but I find it very deceptive for displaying 2D arrays of numbers.
If you do want what pcolor displays as an RGB image, I think you can use getframe().
##### 댓글 수: 5표시 이전 댓글 수: 4숨기기 이전 댓글 수: 4
JMS 2014년 5월 11일
Ok, can we just forget about pcolor() command because I do not have much information about what you are talking about, sorry. Suppose we have the below equations '
x1 = -1; y1 = 0;x2 = 0; y2 = 0;
[x,y] = meshgrid(-5: .2: 5, -5: .2: 5);
V_x1 = ((y-y1)./((x-x1).^2+(y-y1).^2));
V_y1 = ((x-x1)./((x-x1).^2+(y-y1).^2));
V_x2 = (-(y-y2)./((x-x2).^2+(y-y2).^2));
V_y2 = (-(x-x2)./((x-x2).^2+(y-y2).^2));
Vx = V_x1 + V_x2;
Vy = V_y1 + V_y2;
quiver(x, y, Vx, Vy);
hold on
ang = atan2(Vy, Vx);
?
?
"
And I need to have 'RGB' image depending on the angle. How do I do that? I hope this is clear.

댓글을 달려면 로그인하십시오.

Oliver Woodford 2014년 5월 9일
편집: Oliver Woodford 2014년 5월 10일
You can use the sc toolbox, from the File Exchange. In your case, try:
im = sc(ang, 'hsv');
However, there is also a colormap implemented for 2D vector flow fields, which encodes both direction and magnitude. Try:
im = sc(cat(3, Vx, Vy), 'flow');
##### 댓글 수: 4표시 이전 댓글 수: 3숨기기 이전 댓글 수: 3
Oliver Woodford 2014년 5월 12일
The toolbox needs to be on your MATLAB search path .

댓글을 달려면 로그인하십시오.

### 범주

Find more on Surface and Mesh Plots in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by